mirror of https://github.com/ErsatzTV/ErsatzTV.git
Browse Source
* clean up block playout preview logic * fix some bugs with playout templates editor * fix mysql migrationpull/1562/head
8 changed files with 129 additions and 88 deletions
@ -1,18 +1,9 @@
@@ -1,18 +1,9 @@
|
||||
using ErsatzTV.Core.Domain; |
||||
using ErsatzTV.Core.Scheduling; |
||||
using Microsoft.Extensions.Logging; |
||||
|
||||
namespace ErsatzTV.Core.Interfaces.Scheduling; |
||||
|
||||
public interface IBlockPlayoutBuilder |
||||
{ |
||||
Task<Playout> Build(Playout playout, PlayoutBuildMode mode, CancellationToken cancellationToken); |
||||
|
||||
Task<Playout> Build( |
||||
Playout playout, |
||||
PlayoutBuildMode mode, |
||||
ILogger customLogger, |
||||
int daysToBuild, |
||||
bool randomizeStartPoints, |
||||
CancellationToken cancellationToken); |
||||
} |
||||
|
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
namespace ErsatzTV.Core.Interfaces.Scheduling; |
||||
|
||||
public interface IBlockPlayoutPreviewBuilder : IBlockPlayoutBuilder; |
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
using ErsatzTV.Core.Domain; |
||||
using ErsatzTV.Core.Domain.Scheduling; |
||||
using ErsatzTV.Core.Interfaces.Repositories; |
||||
using ErsatzTV.Core.Interfaces.Scheduling; |
||||
using Microsoft.Extensions.Logging; |
||||
using Microsoft.Extensions.Logging.Abstractions; |
||||
|
||||
namespace ErsatzTV.Core.Scheduling.BlockScheduling; |
||||
|
||||
public class BlockPlayoutPreviewBuilder( |
||||
IConfigElementRepository configElementRepository, |
||||
IMediaCollectionRepository mediaCollectionRepository, |
||||
ITelevisionRepository televisionRepository, |
||||
IArtistRepository artistRepository, |
||||
ILogger<BlockPlayoutBuilder> logger) : BlockPlayoutBuilder( |
||||
configElementRepository, |
||||
mediaCollectionRepository, |
||||
televisionRepository, |
||||
artistRepository, |
||||
logger), IBlockPlayoutPreviewBuilder |
||||
{ |
||||
protected override ILogger Logger => NullLogger.Instance; |
||||
|
||||
protected override Task<int> GetDaysToBuild() => Task.FromResult(1); |
||||
|
||||
protected override IMediaCollectionEnumerator GetEnumerator( |
||||
Playout playout, |
||||
BlockItem blockItem, |
||||
DateTimeOffset currentTime, |
||||
string historyKey, |
||||
Map<CollectionKey, List<MediaItem>> collectionMediaItems) |
||||
{ |
||||
IMediaCollectionEnumerator enumerator = base.GetEnumerator(playout, blockItem, currentTime, historyKey, collectionMediaItems); |
||||
|
||||
var collectionKey = CollectionKey.ForBlockItem(blockItem); |
||||
|
||||
enumerator.ResetState( |
||||
new CollectionEnumeratorState |
||||
{ |
||||
Seed = new Random().Next(), |
||||
Index = new Random().Next(collectionMediaItems[collectionKey].Count) |
||||
}); |
||||
|
||||
return enumerator; |
||||
} |
||||
} |
Loading…
Reference in new issue