Browse Source

Remove recurring and years properties and instead implicitly derive from start and end date

pull/2682/head
Carson Kompon 8 months ago committed by Jason Dove
parent
commit
32f93d74bb
No known key found for this signature in database
  1. 10
      ErsatzTV.Core/Scheduling/YamlScheduling/Models/YamlPlayoutSchedule.cs
  2. 19
      ErsatzTV.Core/Scheduling/YamlScheduling/SequentialPlayoutBuilder.cs
  3. 11
      ErsatzTV/Resources/sequential-schedule.schema.json

10
ErsatzTV.Core/Scheduling/YamlScheduling/Models/YamlPlayoutSchedule.cs

@ -12,16 +12,6 @@ public class YamlPlayoutSchedule @@ -12,16 +12,6 @@ public class YamlPlayoutSchedule
[YamlMember(Alias = "end_date", ApplyNamingConventions = false)]
public string EndDate { get; set; }
/// <summary>
/// Specific year(s) this schedule applies to. If empty, applies to all years.
/// </summary>
public List<int> Years { get; set; } = [];
/// <summary>
/// Whether this schedule repeats annually (default: true when no years are specified)
/// </summary>
public bool Recurring { get; set; } = true;
public List<YamlPlayoutInstruction> Reset { get; set; } = [];
public List<YamlPlayoutInstruction> Playout { get; set; } = [];

19
ErsatzTV.Core/Scheduling/YamlScheduling/SequentialPlayoutBuilder.cs

@ -779,23 +779,10 @@ public class SequentialPlayoutBuilder( @@ -779,23 +779,10 @@ public class SequentialPlayoutBuilder(
int currentMonth = date.Month;
int currentDay = date.Day;
// Check if years are specified
if (schedule.Years.Count > 0)
{
if (!schedule.Years.Contains(currentYear))
{
return false;
}
}
else if (!schedule.Recurring)
{
// If not recurring and no years specified, the schedule doesn't apply
return false;
}
// Handle year-specific dates
// Handle year-specific dates (YYYY-MM-DD format)
if (startYear.HasValue && endYear.HasValue)
{
// Dates with years are always non-recurring (one-time events)
var startDate = new DateTime(startYear.Value, startMonth, startDay);
var endDate = new DateTime(endYear.Value, endMonth, endDay);
var currentDate = new DateTime(currentYear, currentMonth, currentDay);
@ -809,7 +796,7 @@ public class SequentialPlayoutBuilder( @@ -809,7 +796,7 @@ public class SequentialPlayoutBuilder(
return false;
}
// Both dates are MM-DD format (recurring)
// Both dates are MM-DD format - always recurring
var currentDayOfYear = new DateTime(currentYear, currentMonth, currentDay).DayOfYear;
var startDayOfYear = new DateTime(currentYear, startMonth, startDay).DayOfYear;
var endDayOfYear = new DateTime(currentYear, endMonth, endDay).DayOfYear;

11
ErsatzTV/Resources/sequential-schedule.schema.json

@ -83,18 +83,9 @@ @@ -83,18 +83,9 @@
},
"end_date": {
"type": "string",
"description": "End date in MM-DD (e.g., '01-31') or YYYY-MM-DD format (e.g., '2024-12-25')",
"description": "End date in MM-DD (e.g., '01-31') or YYYY-MM-DD format (e.g., '2024-12-25'). MM-DD dates recur annually, YYYY-MM-DD dates are one-time events.",
"pattern": "^((\\d{4}-)?(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01]))$"
},
"years": {
"type": "array",
"items": { "type": "integer" },
"description": "Specific years this schedule applies to. If empty, applies to all years (when recurring is true)."
},
"recurring": {
"type": "boolean",
"description": "Whether this schedule repeats annually (default: true when no years are specified)"
},
"reset": {
"description": "Reset instructions for this scheduled playout",
"type": "array",

Loading…
Cancel
Save