search show by language (#149)

This commit is contained in:
Jason Dove
2021-04-06 07:58:45 -05:00
committed by GitHub
parent 0aac702853
commit 2be729c10e
10 changed files with 57 additions and 19 deletions
+14 -7
View File
@@ -53,7 +53,7 @@ namespace ErsatzTV.Infrastructure.Search
public SearchIndex(ILogger<SearchIndex> logger) => _logger = logger;
public int Version => 3;
public int Version => 4;
public Task<bool> Initialize(ILocalFileSystem localFileSystem)
{
@@ -82,7 +82,7 @@ namespace ErsatzTV.Infrastructure.Search
UpdateMovie(movie);
break;
case Show show:
UpdateShow(show);
await UpdateShow(searchRepository, show);
break;
case MusicVideo musicVideo:
UpdateMusicVideo(musicVideo);
@@ -95,9 +95,10 @@ namespace ErsatzTV.Infrastructure.Search
return Unit.Default;
}
public Task<Unit> AddItems(List<MediaItem> items) => UpdateItems(items);
public Task<Unit> AddItems(ISearchRepository searchRepository, List<MediaItem> items) =>
UpdateItems(searchRepository, items);
public Task<Unit> UpdateItems(List<MediaItem> items)
public async Task<Unit> UpdateItems(ISearchRepository searchRepository, List<MediaItem> items)
{
foreach (MediaItem item in items)
{
@@ -107,7 +108,7 @@ namespace ErsatzTV.Infrastructure.Search
UpdateMovie(movie);
break;
case Show show:
UpdateShow(show);
await UpdateShow(searchRepository, show);
break;
case MusicVideo musicVideo:
UpdateMusicVideo(musicVideo);
@@ -115,7 +116,7 @@ namespace ErsatzTV.Infrastructure.Search
}
}
return Task.FromResult(Unit.Default);
return Unit.Default;
}
public Task<Unit> RemoveItems(List<int> ids)
@@ -287,7 +288,7 @@ namespace ErsatzTV.Infrastructure.Search
}
}
private void UpdateShow(Show show)
private async Task UpdateShow(ISearchRepository searchRepository, Show show)
{
Option<ShowMetadata> maybeMetadata = show.ShowMetadata.HeadOrNone();
if (maybeMetadata.IsSome)
@@ -307,6 +308,12 @@ namespace ErsatzTV.Infrastructure.Search
new StringField(JumpLetterField, GetJumpLetter(metadata), Field.Store.YES)
};
List<string> languages = await searchRepository.GetLanguagesForShow(show);
foreach (string lang in languages.Distinct().Filter(s => !string.IsNullOrWhiteSpace(s)))
{
doc.Add(new StringField(LanguageField, lang, Field.Store.NO));
}
if (metadata.ReleaseDate.HasValue)
{
doc.Add(