basic block duration enforcement (#1556)
This commit is contained in:
@@ -68,8 +68,8 @@ public class ReplaceBlockItemsHandler(IDbContextFactory<TvContext> dbContextFact
|
|||||||
|
|
||||||
private static Validation<BaseError, Block> MinutesMustBeValid(ReplaceBlockItems request, Block block) =>
|
private static Validation<BaseError, Block> MinutesMustBeValid(ReplaceBlockItems request, Block block) =>
|
||||||
Optional(block)
|
Optional(block)
|
||||||
.Filter(_ => request.Minutes > 0 && request.Minutes % 15 == 0)
|
.Filter(_ => request.Minutes > 0 && request.Minutes % 15 == 0 && request.Minutes <= 24 * 60)
|
||||||
.ToValidation<BaseError>("Block Minutes must be a positive multiple of 15");
|
.ToValidation<BaseError>("Block duration must be between 15 minutes and 24 hours");
|
||||||
|
|
||||||
private static Validation<BaseError, Block> CollectionTypesMustBeValid(ReplaceBlockItems request, Block block) =>
|
private static Validation<BaseError, Block> CollectionTypesMustBeValid(ReplaceBlockItems request, Block block) =>
|
||||||
request.Items.Map(item => CollectionTypeMustBeValid(item, block)).Sequence().Map(_ => block);
|
request.Items.Map(item => CollectionTypeMustBeValid(item, block)).Sequence().Map(_ => block);
|
||||||
|
|||||||
@@ -56,14 +56,29 @@ public class BlockPlayoutBuilder(
|
|||||||
BlockPlayoutChangeDetection.RemoveItemAndHistory(playout, playoutItem);
|
BlockPlayoutChangeDetection.RemoveItemAndHistory(playout, playoutItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DateTimeOffset currentTime = start;
|
||||||
|
|
||||||
foreach (EffectiveBlock effectiveBlock in updatedEffectiveBlocks)
|
foreach (EffectiveBlock effectiveBlock in updatedEffectiveBlocks)
|
||||||
{
|
{
|
||||||
logger.LogDebug(
|
if (currentTime < effectiveBlock.Start)
|
||||||
"Will schedule block {Block} at {Start}",
|
{
|
||||||
effectiveBlock.Block.Name,
|
currentTime = effectiveBlock.Start;
|
||||||
effectiveBlock.Start);
|
|
||||||
|
|
||||||
DateTimeOffset currentTime = effectiveBlock.Start;
|
logger.LogDebug(
|
||||||
|
"Will schedule block {Block} at {Start}",
|
||||||
|
effectiveBlock.Block.Name,
|
||||||
|
effectiveBlock.Start);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.LogDebug(
|
||||||
|
"Will schedule block {Block} with start {Start} at {ActualStart}",
|
||||||
|
effectiveBlock.Block.Name,
|
||||||
|
effectiveBlock.Start,
|
||||||
|
currentTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTimeOffset blockFinish = effectiveBlock.Start.AddMinutes(effectiveBlock.Block.Minutes);
|
||||||
|
|
||||||
foreach (BlockItem blockItem in effectiveBlock.Block.Items.OrderBy(i => i.Index))
|
foreach (BlockItem blockItem in effectiveBlock.Block.Items.OrderBy(i => i.Index))
|
||||||
{
|
{
|
||||||
@@ -73,6 +88,17 @@ public class BlockPlayoutBuilder(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentTime >= blockFinish)
|
||||||
|
{
|
||||||
|
logger.LogDebug(
|
||||||
|
"Current time {Time} for block {Block} is beyond block finish {Finish}; will stop with this block's items",
|
||||||
|
currentTime,
|
||||||
|
effectiveBlock.Block.Name,
|
||||||
|
blockFinish);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// check for playout history for this collection
|
// check for playout history for this collection
|
||||||
string historyKey = HistoryDetails.KeyForBlockItem(blockItem);
|
string historyKey = HistoryDetails.KeyForBlockItem(blockItem);
|
||||||
//logger.LogDebug("History key for block item {Item} is {Key}", blockItem.Id, historyKey);
|
//logger.LogDebug("History key for block item {Item} is {Key}", blockItem.Id, historyKey);
|
||||||
|
|||||||
Reference in New Issue
Block a user