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:
@@ -25,6 +25,7 @@ type SearchParams struct {
|
|||||||
AuthorFilter string
|
AuthorFilter string
|
||||||
SeriesFilter string
|
SeriesFilter string
|
||||||
GenreFilter string
|
GenreFilter string
|
||||||
|
TagsFilter string
|
||||||
LanguageFilter string
|
LanguageFilter string
|
||||||
YearMin int
|
YearMin int
|
||||||
YearMax int
|
YearMax int
|
||||||
@@ -69,6 +70,7 @@ func (s *SearchService) SearchMediaItemsUnified(ctx context.Context, params Sear
|
|||||||
AuthorFilter: pgtype.Text{String: params.AuthorFilter, Valid: true},
|
AuthorFilter: pgtype.Text{String: params.AuthorFilter, Valid: true},
|
||||||
SeriesFilter: pgtype.Text{String: params.SeriesFilter, Valid: true},
|
SeriesFilter: pgtype.Text{String: params.SeriesFilter, Valid: true},
|
||||||
GenreFilter: pgtype.Text{String: params.GenreFilter, 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},
|
LanguageFilter: pgtype.Text{String: params.LanguageFilter, Valid: true},
|
||||||
YearMin: pgtype.Int4{Int32: int32(params.YearMin), Valid: true},
|
YearMin: pgtype.Int4{Int32: int32(params.YearMin), Valid: true},
|
||||||
YearMax: pgtype.Int4{Int32: int32(params.YearMax), 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
|
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":
|
case "series":
|
||||||
results, err := s.db.SearchSeriesValues(ctx, database.SearchSeriesValuesParams{
|
results, err := s.db.SearchSeriesValues(ctx, database.SearchSeriesValuesParams{
|
||||||
SearchQuery: pgtype.Text{String: params.SearchQuery, Valid: true},
|
SearchQuery: pgtype.Text{String: params.SearchQuery, Valid: true},
|
||||||
|
|||||||
Reference in New Issue
Block a user