feat(backend): report stored pairwise distances in the duplicates response

ListVisible already loads each pair's Hamming distance, but clusterPairs threw
it away. Thread it through: Clusters now returns a Cluster carrying the stored
pairwise distances (indexed once per page), and the list endpoint emits them as
{a, b, distance}. Pairs linked only transitively have no stored distance and are
omitted. Lets the UI show how close each file is to the kept one without a
client-side hash compare (phash exceeds JS's safe-integer range).
This commit is contained in:
2026-06-22 22:42:14 +03:00
parent 281358ff04
commit 78b5e86dd6
5 changed files with 91 additions and 9 deletions
@@ -47,12 +47,16 @@ func (h *DuplicateHandler) List(c *gin.Context) {
}
items := make([]gin.H, len(clusters))
for i, files := range clusters {
fs := make([]fileJSON, len(files))
for j, f := range files {
for i, cl := range clusters {
fs := make([]fileJSON, len(cl.Files))
for j, f := range cl.Files {
fs[j] = toFileJSON(f)
}
items[i] = gin.H{"files": fs}
dists := make([]gin.H, len(cl.Distances))
for j, d := range cl.Distances {
dists[j] = gin.H{"a": d.A, "b": d.B, "distance": d.Distance}
}
items[i] = gin.H{"files": fs, "distances": dists}
}
respondJSON(c, http.StatusOK, gin.H{
"items": items,