more scheduling fixes (#732)

* fix skipping days with fixed start times

* fix playouts getting "stuck" on the same items

* rebuild all playouts

* update dependencies
This commit is contained in:
Jason Dove
2022-04-12 09:19:13 -05:00
committed by GitHub
parent 5d6a6d3a76
commit af39d93442
9 changed files with 3999 additions and 17 deletions
@@ -1,4 +1,5 @@
using ErsatzTV.Core.Domain;
using Destructurama;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Domain.Filler;
using ErsatzTV.Core.Interfaces.Repositories;
using ErsatzTV.Core.Scheduling;
@@ -21,6 +22,7 @@ namespace ErsatzTV.Core.Tests.Scheduling
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Console()
.Destructure.UsingAttributes()
.CreateLogger();
ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(Log.Logger);
@@ -1694,6 +1696,32 @@ namespace ErsatzTV.Core.Tests.Scheduling
playout.Anchor.NextStartOffset.Should().Be(DateTime.Today.AddDays(1));
playout.ProgramScheduleAnchors.Count.Should().Be(1);
playout.ProgramScheduleAnchors.Head().EnumeratorState.Index.Should().Be(0);
PlayoutProgramScheduleAnchor headAnchor = playout.ProgramScheduleAnchors.Head();
// throw in a detractor anchor - playout builder should prioritize the "continue" anchor
playout.ProgramScheduleAnchors.Insert(
0,
new PlayoutProgramScheduleAnchor
{
Id = headAnchor.Id + 1,
Collection = headAnchor.Collection,
CollectionId = headAnchor.CollectionId,
Playout = playout,
PlayoutId = playout.Id,
AnchorDate = DateTime.Today.ToUniversalTime(),
CollectionType = headAnchor.CollectionType,
EnumeratorState = new CollectionEnumeratorState
{ Index = headAnchor.EnumeratorState.Index + 1, Seed = headAnchor.EnumeratorState.Seed },
MediaItem = headAnchor.MediaItem,
MediaItemId = headAnchor.MediaItemId,
MultiCollection = headAnchor.MultiCollection,
MultiCollectionId = headAnchor.MultiCollectionId,
ProgramSchedule = headAnchor.ProgramSchedule,
ProgramScheduleId = headAnchor.ProgramScheduleId,
SmartCollection = headAnchor.SmartCollection,
SmartCollectionId = headAnchor.SmartCollectionId
});
// continue 1h later
DateTimeOffset start2 = HoursAfterMidnight(1);
@@ -3,7 +3,6 @@ using ErsatzTV.Core.Domain.Filler;
using ErsatzTV.Core.Interfaces.Scheduling;
using ErsatzTV.Core.Scheduling;
using FluentAssertions;
using Microsoft.Extensions.Logging;
using Moq;
using NUnit.Framework;
@@ -286,6 +285,35 @@ public class PlayoutModeSchedulerBaseTests : SchedulerTestBase
}
}
[TestFixture]
public class GetStartTimeAfter
{
[Test]
public void Should_Compare_Time_As_Local_Time()
{
var enumerator = new Mock<IScheduleItemsEnumerator>();
var state = new PlayoutBuilderState(
enumerator.Object,
None,
None,
false,
false,
0,
DateTime.Today.AddHours(6).ToUniversalTime());
var scheduleItem = new ProgramScheduleItemOne
{
StartTime = TimeSpan.FromHours(6)
};
DateTimeOffset result =
PlayoutModeSchedulerBase<ProgramScheduleItem>.GetStartTimeAfter(state, scheduleItem);
result.Should().Be(DateTime.Today.AddHours(6));
}
}
private static Movie TestMovie(int id, TimeSpan duration, DateTime aired) =>
new()
{