From bb8b4f9f635c3050258465387fb247547c6ce47b Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Wed, 25 Mar 2026 20:38:11 -0400 Subject: [PATCH] feat: implement tags filter in service layer - Add TagsFilter string to SearchParams struct - Update dbParams building to include tags_filter - Add tags case to SearchFieldValues service for autocomplete - Handle SearchTagsValues query results Enables the backend service layer to process tag filtering requests and provide autocomplete suggestions for tag values. Relates to IMPLEMENTATION_TAGS_FILTER.md Phase 2 --- internal/services/search.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/internal/services/search.go b/internal/services/search.go index 6ec4f8a..7a20861 100644 --- a/internal/services/search.go +++ b/internal/services/search.go @@ -25,6 +25,7 @@ type SearchParams struct { AuthorFilter string SeriesFilter string GenreFilter string + TagsFilter string LanguageFilter string YearMin int YearMax int @@ -69,6 +70,7 @@ func (s *SearchService) SearchMediaItemsUnified(ctx context.Context, params Sear AuthorFilter: pgtype.Text{String: params.AuthorFilter, Valid: true}, SeriesFilter: pgtype.Text{String: params.SeriesFilter, Valid: true}, GenreFilter: pgtype.Text{String: params.GenreFilter, Valid: true}, + TagsFilter: pgtype.Text{String: params.TagsFilter, Valid: true}, LanguageFilter: pgtype.Text{String: params.LanguageFilter, Valid: true}, YearMin: pgtype.Int4{Int32: int32(params.YearMin), Valid: true}, YearMax: pgtype.Int4{Int32: int32(params.YearMax), Valid: true}, @@ -150,6 +152,23 @@ func (s *SearchService) SearchFieldValues(ctx context.Context, params FieldSearc } return fieldValues, nil + case "tags": + results, err := s.db.SearchTagsValues(ctx, database.SearchTagsValuesParams{ + SearchQuery: pgtype.Text{String: params.SearchQuery, Valid: true}, + UserID: params.UserID, + LibraryID: params.LibraryID, + Limit: pgtype.Int4{Int32: int32(params.Limit), Valid: true}, + Offset: pgtype.Int4{Int32: int32(params.Offset), Valid: true}, + }) + if err != nil { + return nil, err + } + fieldValues := make([]FieldValue, len(results)) + for i, r := range results { + fieldValues[i] = FieldValue{Value: r.Value, Count: r.Count, Score: r.Score} + } + return fieldValues, nil + case "series": results, err := s.db.SearchSeriesValues(ctx, database.SearchSeriesValuesParams{ SearchQuery: pgtype.Text{String: params.SearchQuery, Valid: true},