show collection name in some error messages (#612)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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>(
|
||||
|
||||
Reference in New Issue
Block a user