Compare commits
2 Commits
69601fe512
...
c235d11d03
| Author | SHA1 | Date | |
|---|---|---|---|
| c235d11d03 | |||
| 361a01a025 |
@@ -1611,9 +1611,15 @@ function updateClusterAfterMerge(sourceGroupId: string, targetGroupId: string) {
|
||||
|
||||
const idx = clusters.findIndex((c: any) => c.identity_uuid === sourceGroupId)
|
||||
if (idx >= 0) {
|
||||
clusters.splice(idx, 1)
|
||||
clusters.splice(idx, 1) // ← Remove empty source group
|
||||
}
|
||||
}
|
||||
|
||||
// Also remove from clusterAsPending computed
|
||||
const idx2 = clusterAsPending.value.findIndex((c: any) => c.identity_uuid === sourceGroupId)
|
||||
if (idx2 >= 0) {
|
||||
clusterAsPending.value.splice(idx2, 1)
|
||||
}
|
||||
}
|
||||
|
||||
async function batchDeleteFaces() {
|
||||
@@ -1706,23 +1712,31 @@ async function batchMergeGroups() {
|
||||
}
|
||||
|
||||
const groupIds = Array.from(selectedGroups.value)
|
||||
console.log('[batchMergeGroups] groupIds:', groupIds)
|
||||
|
||||
mergeCandidateGroups.value = clusterAsPending.value.filter((c: any) => groupIds.includes(c.identity_uuid))
|
||||
console.log('[batchMergeGroups] mergeCandidateGroups:', mergeCandidateGroups.value.length)
|
||||
|
||||
showMergeTargetModal.value = true
|
||||
}
|
||||
|
||||
async function executeMerge(targetGroupId: string) {
|
||||
console.log('[executeMerge] targetGroupId:', targetGroupId)
|
||||
showMergeTargetModal.value = false
|
||||
|
||||
const targetGroup = clusterAsPending.value.find((c: any) => c.identity_uuid === targetGroupId)
|
||||
console.log('[executeMerge] targetGroup:', targetGroup)
|
||||
if (!targetGroup) return
|
||||
|
||||
const targetTraceId = targetGroup.trace_ids?.[0]
|
||||
console.log('[executeMerge] targetTraceId:', targetTraceId, typeof targetTraceId)
|
||||
if (!targetTraceId) {
|
||||
alert('Target group has no traces')
|
||||
return
|
||||
}
|
||||
|
||||
const targetTrace = clusterTracesMap.value[String(targetTraceId)]
|
||||
console.log('[executeMerge] targetTrace:', targetTrace)
|
||||
const targetFileUuid = targetTrace?.file_uuid
|
||||
if (!targetFileUuid) {
|
||||
alert('Target trace has no file_uuid')
|
||||
@@ -1732,6 +1746,7 @@ async function executeMerge(targetGroupId: string) {
|
||||
const groupIds = Array.from(selectedGroups.value)
|
||||
const sourceGroupIds = groupIds.filter(id => id !== targetGroupId)
|
||||
const sourceGroups = clusterAsPending.value.filter((c: any) => sourceGroupIds.includes(c.identity_uuid))
|
||||
console.log('[executeMerge] sourceGroups:', sourceGroups.length)
|
||||
|
||||
let totalTraces = 0
|
||||
let validTraces = 0
|
||||
@@ -1743,6 +1758,8 @@ async function executeMerge(targetGroupId: string) {
|
||||
}
|
||||
}
|
||||
|
||||
console.log('[executeMerge] totalTraces:', totalTraces, 'validTraces:', validTraces)
|
||||
|
||||
if (validTraces === 0) {
|
||||
alert('No valid traces to merge (all missing file_uuid)')
|
||||
return
|
||||
@@ -1753,31 +1770,45 @@ async function executeMerge(targetGroupId: string) {
|
||||
operationLoading.value = true
|
||||
operationMessage.value = `Merging ${validTraces} trace(s)...`
|
||||
|
||||
let successCount = 0
|
||||
let failCount = 0
|
||||
|
||||
for (const g of sourceGroups) {
|
||||
for (const srcTraceId of g.trace_ids || []) {
|
||||
const srcTrace = clusterTracesMap.value[String(srcTraceId)]
|
||||
const srcFileUuid = srcTrace?.file_uuid
|
||||
if (!srcFileUuid) {
|
||||
console.warn('[merge] skipping trace without file_uuid:', srcTraceId)
|
||||
failCount++
|
||||
continue
|
||||
}
|
||||
if (srcFileUuid !== targetFileUuid) {
|
||||
console.warn('[merge] skipping cross-file trace:', srcTraceId, srcFileUuid, '!=', targetFileUuid)
|
||||
failCount++
|
||||
continue
|
||||
}
|
||||
try {
|
||||
console.log('[executeMerge] calling merge_trace:', {
|
||||
file_uuid: srcFileUuid,
|
||||
source_id: srcTraceId,
|
||||
target_id: targetTraceId
|
||||
})
|
||||
await apiCall('merge_trace', {
|
||||
file_uuid: srcFileUuid,
|
||||
source_id: srcTraceId,
|
||||
target_id: targetTraceId
|
||||
})
|
||||
successCount++
|
||||
updateClusterAfterMerge(g.identity_uuid, targetGroupId)
|
||||
} catch (e) {
|
||||
console.error('Merge trace failed:', srcTraceId, e)
|
||||
failCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('[executeMerge] completed:', successCount, 'success,', failCount, 'failed')
|
||||
|
||||
operationLoading.value = false
|
||||
operationMessage.value = ''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user