fix season display bug (#1511)
This commit is contained in:
@@ -37,6 +37,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- Fix scanning Jellyfin libraries when library options and/or path infos are not returned from Jellyfin API
|
- Fix scanning Jellyfin libraries when library options and/or path infos are not returned from Jellyfin API
|
||||||
- Fix error indexing music videos in `File Not Found` state
|
- Fix error indexing music videos in `File Not Found` state
|
||||||
- Fix bug scheduling duration filler when filler collection contains item with zero duration
|
- Fix bug scheduling duration filler when filler collection contains item with zero duration
|
||||||
|
- Fix bug displaying television seasons for shows that have no year metadata
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Upgrade ffmpeg to 6.1, which is now *required* for all installs
|
- Upgrade ffmpeg to 6.1, which is now *required* for all installs
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using ErsatzTV.Core.Domain;
|
|||||||
using ErsatzTV.Core.Errors;
|
using ErsatzTV.Core.Errors;
|
||||||
using ErsatzTV.Core.Interfaces.Repositories;
|
using ErsatzTV.Core.Interfaces.Repositories;
|
||||||
using ErsatzTV.Core.Metadata;
|
using ErsatzTV.Core.Metadata;
|
||||||
|
using ErsatzTV.Infrastructure.Extensions;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
@@ -173,27 +174,35 @@ public class TelevisionRepository : ITelevisionRepository
|
|||||||
|
|
||||||
public async Task<List<Season>> GetPagedSeasons(int televisionShowId, int pageNumber, int pageSize)
|
public async Task<List<Season>> GetPagedSeasons(int televisionShowId, int pageNumber, int pageSize)
|
||||||
{
|
{
|
||||||
|
var result = new List<Season>();
|
||||||
|
|
||||||
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync();
|
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
List<int> showIds = await dbContext.Connection.QueryAsync<int>(
|
Option<ShowMetadata> maybeShowMetadata = await dbContext.ShowMetadata
|
||||||
@"SELECT m1.ShowId
|
.SelectOneAsync(sm => sm.Id, sm => sm.ShowId == televisionShowId);
|
||||||
FROM ShowMetadata m1
|
|
||||||
LEFT OUTER JOIN ShowMetadata m2 ON m2.ShowId = @ShowId
|
|
||||||
WHERE m1.Title = m2.Title AND m1.Year = m2.Year",
|
|
||||||
new { ShowId = televisionShowId })
|
|
||||||
.Map(results => results.ToList());
|
|
||||||
|
|
||||||
return await dbContext.Seasons
|
foreach (ShowMetadata showMetadata in maybeShowMetadata)
|
||||||
.AsNoTracking()
|
{
|
||||||
.Where(s => showIds.Contains(s.ShowId))
|
List<int> showIds = await dbContext.ShowMetadata
|
||||||
.Include(s => s.SeasonMetadata)
|
.Filter(sm => sm.Title == showMetadata.Title && sm.Year == showMetadata.Year)
|
||||||
.ThenInclude(sm => sm.Artwork)
|
.Map(sm => sm.ShowId)
|
||||||
.Include(s => s.Show)
|
.ToListAsync();
|
||||||
.ThenInclude(s => s.ShowMetadata)
|
|
||||||
.OrderBy(s => s.SeasonNumber)
|
result.AddRange(
|
||||||
.Skip((pageNumber - 1) * pageSize)
|
await dbContext.Seasons
|
||||||
.Take(pageSize)
|
.AsNoTracking()
|
||||||
.ToListAsync();
|
.Where(s => showIds.Contains(s.ShowId))
|
||||||
|
.Include(s => s.SeasonMetadata)
|
||||||
|
.ThenInclude(sm => sm.Artwork)
|
||||||
|
.Include(s => s.Show)
|
||||||
|
.ThenInclude(s => s.ShowMetadata)
|
||||||
|
.OrderBy(s => s.SeasonNumber)
|
||||||
|
.Skip((pageNumber - 1) * pageSize)
|
||||||
|
.Take(pageSize)
|
||||||
|
.ToListAsync());
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GetEpisodeCount(int seasonId)
|
public async Task<int> GetEpisodeCount(int seasonId)
|
||||||
|
|||||||
Reference in New Issue
Block a user