Skip to content

Commit 27ab865

Browse files
committed
fix: update image duplicate checker UI and API handling
- Fixes 400 error in ImageDuplicateChecker - Updates UI and frontend types - Fixes tools casing
1 parent df8c025 commit 27ab865

5 files changed

Lines changed: 605 additions & 212 deletions

File tree

pkg/sqlite/image.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,13 +1105,29 @@ func (qb *ImageStore) FindDuplicates(ctx context.Context, distance int) ([][]*mo
11051105

11061106
var hashes []*utils.Phash
11071107
if err := imageRepository.queryFunc(ctx, query, nil, false, func(rows *sqlx.Rows) error {
1108+
var sq struct {
1109+
ID int `db:"id"`
1110+
Phash *string `db:"phash"`
1111+
}
1112+
if err := rows.StructScan(&sq); err != nil {
1113+
return err
1114+
}
1115+
1116+
if sq.Phash == nil {
1117+
return nil
1118+
}
1119+
1120+
hashInt, err := utils.StringToPhash(*sq.Phash)
1121+
if err != nil {
1122+
return nil
1123+
}
1124+
11081125
phash := utils.Phash{
1126+
ID: sq.ID,
1127+
Hash: hashInt,
11091128
Bucket: -1,
11101129
Duration: -1,
11111130
}
1112-
if err := rows.StructScan(&phash); err != nil {
1113-
return err
1114-
}
11151131

11161132
hashes = append(hashes, &phash)
11171133
return nil

pkg/sqlite/image_filter.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ func (qb *imageFilterHandler) missingCriterionHandler(isMissing *string) criteri
185185
case "tags":
186186
imageRepository.tags.join(f, "tags_join", "images.id")
187187
f.addWhere("tags_join.image_id IS NULL")
188+
case "phash":
189+
f.addInnerJoin("images_files", "", "images_files.image_id = images.id")
190+
f.addLeftJoin(fingerprintTable, "fingerprints_phash", "images_files.file_id = fingerprints_phash.file_id AND fingerprints_phash.type = 'phash'")
191+
f.addWhere("fingerprints_phash.fingerprint IS NULL")
188192
default:
189193
if err := validateIsMissing(*isMissing, []string{
190194
"title", "details", "photographer", "date", "code", "rating",

ui/v2.5/graphql/queries/image.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ query FindImage($id: ID!, $checksum: String) {
3636
}
3737
}
3838

39-
query FindDuplicateImages($distance: Int) {
39+
query FindDuplicateImages($distance: Int!) {
4040
findDuplicateImages(distance: $distance) {
4141
...ImageData
4242
}

0 commit comments

Comments
 (0)