Add missing seasons endpoint and update metadata handling
Implemented a new endpoint to retrieve missing seasons for shows, enhancing the MetadataEndpoints class. Updated the IMetadataProvider interface to include a method for fetching season numbers. Adjusted the ShowSummaryDto to include other genres and modified the ListShowsQueryHandler to handle multiple genres. Enhanced the Omdb and Tmdb metadata providers to support season number retrieval. Updated frontend components to integrate missing seasons functionality, including API calls and UI elements for displaying missing seasons reports.
This commit is contained in:
@@ -32,16 +32,11 @@ public sealed class ListShowsQueryHandler(IAppDbContext dbContext)
|
||||
|
||||
var shows = await filtered.OrderBy(s => s.Name).ToListAsync(cancellationToken);
|
||||
|
||||
// Названия только для основных жанров — в списке показывается один.
|
||||
var primaryIds = shows
|
||||
.Select(s => s.PrimaryGenreId)
|
||||
.Where(id => id is not null)
|
||||
.Select(id => id!.Value)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
// Названия всех проставленных жанров: основной показывается в колонке, прочие — под «…».
|
||||
var genreIds = shows.SelectMany(s => s.Genres.Select(g => g.GenreId)).Distinct().ToList();
|
||||
var genreNames = await dbContext
|
||||
.Genres.AsNoTracking()
|
||||
.Where(g => primaryIds.Contains(g.Id))
|
||||
.Where(g => genreIds.Contains(g.Id))
|
||||
.ToDictionaryAsync(g => g.Id, g => g.Name, cancellationToken);
|
||||
|
||||
// Имена ассетов нужны, чтобы распознать сезоны (номера в модели не хранятся).
|
||||
@@ -81,7 +76,14 @@ public sealed class ListShowsQueryHandler(IAppDbContext dbContext)
|
||||
s.PrimaryGenreId is { } primaryId
|
||||
&& genreNames.TryGetValue(primaryId, out var g)
|
||||
? g
|
||||
: null
|
||||
: null,
|
||||
[
|
||||
.. s
|
||||
.Genres.Where(x => !x.IsPrimary)
|
||||
.Select(x => genreNames.GetValueOrDefault(x.GenreId))
|
||||
.OfType<string>()
|
||||
.Order(StringComparer.OrdinalIgnoreCase),
|
||||
]
|
||||
);
|
||||
})
|
||||
.ToList();
|
||||
|
||||
Reference in New Issue
Block a user