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
This commit is contained in:
2026-03-25 20:38:11 -04:00
parent 00840c2fe1
commit bb8b4f9f63
+19
View File
@@ -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},