fix: moveToGroup should rename traces, not merge them
Changed from apiCall('merge_trace', ...) to updateTraceProfileGroup(name=targetGroup.name).
This just changes the trace profile name to join the target group,
without actually merging trace data together.
This commit is contained in:
@@ -1814,43 +1814,37 @@ async function batchMoveFaces() {
|
|||||||
async function moveToGroup(targetGroup: any) {
|
async function moveToGroup(targetGroup: any) {
|
||||||
showMoveFacesModal.value = false
|
showMoveFacesModal.value = false
|
||||||
|
|
||||||
const targetTraceId = targetGroup.trace_ids?.[0]
|
|
||||||
if (!targetTraceId) {
|
|
||||||
alert('Target group has no traces')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const targetTrace = clusterTracesMap.value[String(targetTraceId)]
|
|
||||||
const targetFileUuid = targetTrace?.file_uuid
|
|
||||||
if (!targetFileUuid) {
|
|
||||||
alert('Target trace has no file_uuid')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const traceList: { file_uuid: string; trace_id: number }[] = []
|
const traceList: { file_uuid: string; trace_id: number }[] = []
|
||||||
for (const key of selectedFaces.value) {
|
for (const key of selectedFaces.value) {
|
||||||
const [file_uuid, trace_id] = key.split(':')
|
const [file_uuid, trace_id] = key.split(':')
|
||||||
traceList.push({ file_uuid, trace_id: parseInt(trace_id) })
|
traceList.push({ file_uuid, trace_id: parseInt(trace_id) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!traceList.length) return
|
||||||
if (!confirm(`Move ${traceList.length} trace(s) to "${targetGroup.name}"?`)) return
|
if (!confirm(`Move ${traceList.length} trace(s) to "${targetGroup.name}"?`)) return
|
||||||
|
|
||||||
operationLoading.value = true
|
operationLoading.value = true
|
||||||
operationMessage.value = `Moving ${traceList.length} trace(s)...`
|
operationMessage.value = `Moving ${traceList.length} trace(s)...`
|
||||||
|
|
||||||
|
// Group by file_uuid for batch update
|
||||||
|
const byFile: Record<string, number[]> = {}
|
||||||
for (const t of traceList) {
|
for (const t of traceList) {
|
||||||
|
if (!byFile[t.file_uuid]) byFile[t.file_uuid] = []
|
||||||
|
byFile[t.file_uuid].push(t.trace_id)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const [fileUuid, traceIds] of Object.entries(byFile)) {
|
||||||
try {
|
try {
|
||||||
await apiCall('merge_trace', {
|
await updateTraceProfileGroup(fileUuid, traceIds, { name: targetGroup.name })
|
||||||
file_uuid: t.file_uuid,
|
|
||||||
source_id: t.trace_id,
|
|
||||||
target_id: targetTraceId
|
|
||||||
})
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Move trace failed:', t, e)
|
console.error('Move traces failed:', fileUuid, traceIds, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
removeTracesFromCache(selectedFaces.value)
|
// Refresh cluster results
|
||||||
|
if (selectedFileUuid.value) {
|
||||||
|
await loadClusterResults()
|
||||||
|
}
|
||||||
|
|
||||||
operationLoading.value = false
|
operationLoading.value = false
|
||||||
operationMessage.value = ''
|
operationMessage.value = ''
|
||||||
|
|||||||
Reference in New Issue
Block a user