Files
ersatztv/ErsatzTV.Application/Search/Queries/QuerySearchIndexAllItemsHandler.cs
T
Jason DoveandGitHub 0d301df5e8 remove external dependencies (bugsnag, trakt) (#2840)
* remove bugsnag

* remove trakt client id (that will expire)
2026-02-26 10:43:48 -06:00

29 lines
1.6 KiB
C#

using ErsatzTV.Core.Interfaces.Search;
using ErsatzTV.Infrastructure.Search;
namespace ErsatzTV.Application.Search;
public class QuerySearchIndexAllItemsHandler(ISearchIndex searchIndex)
: IRequestHandler<QuerySearchIndexAllItems, SearchResultAllItemsViewModel>
{
public async Task<SearchResultAllItemsViewModel> Handle(
QuerySearchIndexAllItems request,
CancellationToken cancellationToken) =>
new(
await GetIds(LuceneSearchIndex.MovieType, request.Query, cancellationToken),
await GetIds(LuceneSearchIndex.ShowType, request.Query, cancellationToken),
await GetIds(LuceneSearchIndex.SeasonType, request.Query, cancellationToken),
await GetIds(LuceneSearchIndex.EpisodeType, request.Query, cancellationToken),
await GetIds(LuceneSearchIndex.ArtistType, request.Query, cancellationToken),
await GetIds(LuceneSearchIndex.MusicVideoType, request.Query, cancellationToken),
await GetIds(LuceneSearchIndex.OtherVideoType, request.Query, cancellationToken),
await GetIds(LuceneSearchIndex.SongType, request.Query, cancellationToken),
await GetIds(LuceneSearchIndex.ImageType, request.Query, cancellationToken),
await GetIds(LuceneSearchIndex.RemoteStreamType, request.Query, cancellationToken));
private async Task<List<int>> GetIds(string type, string query, CancellationToken cancellationToken) =>
(await searchIndex.Search($"type:{type} AND ({query})", string.Empty, 0, 0, cancellationToken)).Items
.Map(i => i.Id)
.ToList();
}