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:
2026-08-01 05:50:10 +08:00
parent 1c0f15664e
commit beea6b1c35

View File

@@ -1814,43 +1814,37 @@ async function batchMoveFaces() {
async function moveToGroup(targetGroup: any) {
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 }[] = []
for (const key of selectedFaces.value) {
const [file_uuid, trace_id] = key.split(':')
traceList.push({ file_uuid, trace_id: parseInt(trace_id) })
}
if (!traceList.length) return
if (!confirm(`Move ${traceList.length} trace(s) to "${targetGroup.name}"?`)) return
operationLoading.value = true
operationMessage.value = `Moving ${traceList.length} trace(s)...`
// Group by file_uuid for batch update
const byFile: Record<string, number[]> = {}
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 {
await apiCall('merge_trace', {
file_uuid: t.file_uuid,
source_id: t.trace_id,
target_id: targetTraceId
})
await updateTraceProfileGroup(fileUuid, traceIds, { name: targetGroup.name })
} 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
operationMessage.value = ''