Browse Source

show collection name in some error messages (#612)

pull/613/head
Jason Dove 4 years ago committed by GitHub
parent
commit
0c53a4509c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 1
      ErsatzTV.Core.Tests/Fakes/FakeMediaCollectionRepository.cs
  3. 1
      ErsatzTV.Core/Interfaces/Repositories/IMediaCollectionRepository.cs
  4. 14
      ErsatzTV.Core/Scheduling/PlayoutBuilder.cs
  5. 31
      ErsatzTV.Infrastructure/Data/Repositories/MediaCollectionRepository.cs

1
CHANGELOG.md

@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
- Intermittent watermarks will now fade in and out
- Show collection name in some playout build error messages
## [0.4.0-alpha] - 2022-01-29
### Fixed

1
ErsatzTV.Core.Tests/Fakes/FakeMediaCollectionRepository.cs

@ -37,5 +37,6 @@ namespace ErsatzTV.Core.Tests.Fakes @@ -37,5 +37,6 @@ namespace ErsatzTV.Core.Tests.Fakes
throw new NotSupportedException();
public Task<bool> IsCustomPlaybackOrder(int collectionId) => false.AsTask();
public Task<Option<string>> GetNameFromKey(CollectionKey emptyCollection) => Option<string>.None.AsTask();
}
}

1
ErsatzTV.Core/Interfaces/Repositories/IMediaCollectionRepository.cs

@ -18,5 +18,6 @@ namespace ErsatzTV.Core.Interfaces.Repositories @@ -18,5 +18,6 @@ namespace ErsatzTV.Core.Interfaces.Repositories
Task<List<int>> PlayoutIdsUsingMultiCollection(int multiCollectionId);
Task<List<int>> PlayoutIdsUsingSmartCollection(int smartCollectionId);
Task<bool> IsCustomPlaybackOrder(int collectionId);
Task<Option<string>> GetNameFromKey(CollectionKey emptyCollection);
}
}

14
ErsatzTV.Core/Scheduling/PlayoutBuilder.cs

@ -72,10 +72,24 @@ namespace ErsatzTV.Core.Scheduling @@ -72,10 +72,24 @@ namespace ErsatzTV.Core.Scheduling
Option<CollectionKey> maybeEmptyCollection = await CheckForEmptyCollections(collectionMediaItems);
foreach (CollectionKey emptyCollection in maybeEmptyCollection)
{
Option<string> maybeName = await _mediaCollectionRepository.GetNameFromKey(emptyCollection);
if (maybeName.IsSome)
{
foreach (string name in maybeName)
{
_logger.LogError(
"Unable to rebuild playout; {CollectionType} {CollectionName} has no valid items!",
emptyCollection.CollectionType,
name);
}
}
else
{
_logger.LogError(
"Unable to rebuild playout; collection {@CollectionKey} has no valid items!",
emptyCollection);
}
return playout;
}

31
ErsatzTV.Infrastructure/Data/Repositories/MediaCollectionRepository.cs

@ -355,6 +355,37 @@ namespace ErsatzTV.Infrastructure.Data.Repositories @@ -355,6 +355,37 @@ namespace ErsatzTV.Infrastructure.Data.Repositories
@"SELECT IFNULL(MIN(UseCustomPlaybackOrder), 0) FROM Collection WHERE Id = @CollectionId",
new { CollectionId = collectionId });
public async Task<Option<string>> GetNameFromKey(CollectionKey emptyCollection)
{
await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync();
return emptyCollection.CollectionType switch
{
ProgramScheduleItemCollectionType.Artist => await dbContext.Artists.Include(a => a.ArtistMetadata)
.SelectOneAsync(a => a.Id, a => a.Id == emptyCollection.MediaItemId.Value)
.MapT(a => a.ArtistMetadata.Head().Title),
ProgramScheduleItemCollectionType.Collection => await dbContext.Collections
.SelectOneAsync(c => c.Id, c => c.Id == emptyCollection.CollectionId.Value)
.MapT(c => c.Name),
ProgramScheduleItemCollectionType.MultiCollection => await dbContext.MultiCollections
.SelectOneAsync(c => c.Id, c => c.Id == emptyCollection.MultiCollectionId.Value)
.MapT(c => c.Name),
ProgramScheduleItemCollectionType.SmartCollection => await dbContext.SmartCollections
.SelectOneAsync(c => c.Id, c => c.Id == emptyCollection.SmartCollectionId.Value)
.MapT(c => c.Name),
ProgramScheduleItemCollectionType.TelevisionSeason => await dbContext.Seasons
.Include(s => s.SeasonMetadata)
.Include(s => s.Show)
.ThenInclude(s => s.ShowMetadata)
.SelectOneAsync(a => a.Id, a => a.Id == emptyCollection.MediaItemId.Value)
.MapT(s => $"{s.Show.ShowMetadata.Head().Title} Season {s.SeasonNumber}"),
ProgramScheduleItemCollectionType.TelevisionShow => await dbContext.Shows.Include(s => s.ShowMetadata)
.SelectOneAsync(a => a.Id, a => a.Id == emptyCollection.MediaItemId.Value)
.MapT(s => s.ShowMetadata.Head().Title),
_ => None
};
}
private async Task<List<Movie>> GetMovieItems(TvContext dbContext, int collectionId)
{
IEnumerable<int> ids = await _dbConnection.QueryAsync<int>(

Loading…
Cancel
Save