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