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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user