diff --git a/internal/query/photo_results.go b/internal/query/photo_results.go index 6be983d76..4b7abb52c 100644 --- a/internal/query/photo_results.go +++ b/internal/query/photo_results.go @@ -14,6 +14,7 @@ import ( // PhotoResult contains found photos and their main file plus other meta data. type PhotoResult struct { ID uint `json:"-"` + CompositeID string `json:"ID"` UUID string `json:"DocumentID,omitempty"` PhotoUID string `json:"UID"` PhotoType string `json:"Type"` @@ -124,6 +125,7 @@ func (m PhotoResults) Merged() (PhotoResults, int, error) { } file.ID = res.FileID + res.CompositeID = fmt.Sprintf("%d-%d", res.ID, res.FileID) if lastId == res.ID && i > 0 { merged[i-1].Files = append(merged[i-1].Files, file) diff --git a/internal/query/photo_search.go b/internal/query/photo_search.go index 5f6d2eaac..4c848f45c 100644 --- a/internal/query/photo_search.go +++ b/internal/query/photo_search.go @@ -27,7 +27,7 @@ func PhotoSearch(f form.PhotoSearch) (results PhotoResults, count int, err error // Main search query, avoids (slow) left joins. s = s.Table("photos"). - Select(`photos.*, + Select(`photos.*, photos.id AS composite_id, files.id AS file_id, files.file_uid, files.instance_id, files.file_primary, files.file_missing, files.file_name, files.file_root, files.file_hash, files.file_codec, files.file_type, files.file_mime, files.file_width, files.file_height, files.file_portrait, files.file_aspect_ratio, files.file_orientation, files.file_main_color,