Enhance code readability and maintainability by refactoring various components. Update formatting commands in CLAUDE.md for csharpier integration. Simplify method signatures in SegmentFiles, UploadLimits, and multiple endpoint classes for improved clarity. Adjust query handlers and command handlers to streamline parameter handling and enhance consistency across the application.
This commit is contained in:
@@ -68,7 +68,9 @@ public static class ElementSelector
|
||||
if (current is not null && HasUnitsLeft(slot, current))
|
||||
return Continue(slot, current);
|
||||
|
||||
var currentIndex = current is null ? -1 : ordered.FindIndex(e => e.ElementId == current.ElementId);
|
||||
var currentIndex = current is null
|
||||
? -1
|
||||
: ordered.FindIndex(e => e.ElementId == current.ElementId);
|
||||
var nextIndex = currentIndex + 1;
|
||||
|
||||
if (nextIndex >= ordered.Count)
|
||||
@@ -104,11 +106,12 @@ public static class ElementSelector
|
||||
var withinLimit = ApplyRepeatLimit(slot, playable, moment);
|
||||
|
||||
var cooldown = TimeSpan.FromDays(Math.Max(0, slot.Strategy.CooldownDays));
|
||||
var eligible = cooldown <= TimeSpan.Zero
|
||||
? withinLimit
|
||||
: withinLimit
|
||||
.Where(e => e.LastPlayedUtc is not { } last || moment - last >= cooldown)
|
||||
.ToList();
|
||||
var eligible =
|
||||
cooldown <= TimeSpan.Zero
|
||||
? withinLimit
|
||||
: withinLimit
|
||||
.Where(e => e.LastPlayedUtc is not { } last || moment - last >= cooldown)
|
||||
.ToList();
|
||||
|
||||
var exhausted = eligible.Count == 0;
|
||||
if (exhausted)
|
||||
|
||||
@@ -123,16 +123,7 @@ public static class SchedulePlanner
|
||||
)
|
||||
);
|
||||
|
||||
trace = new PlanTrace(
|
||||
slot.SlotId,
|
||||
slot.SlotKind,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
drift,
|
||||
snapped
|
||||
);
|
||||
trace = new PlanTrace(slot.SlotId, slot.SlotKind, null, null, null, null, drift, snapped);
|
||||
return cursor;
|
||||
}
|
||||
|
||||
@@ -291,12 +282,7 @@ public static class SchedulePlanner
|
||||
slot.JunctionAfter,
|
||||
cursor,
|
||||
limit,
|
||||
new JunctionPlacement(
|
||||
slot.SlotId,
|
||||
run.PreviousShowId,
|
||||
null,
|
||||
ElementChanged: true
|
||||
),
|
||||
new JunctionPlacement(slot.SlotId, run.PreviousShowId, null, ElementChanged: true),
|
||||
run.Junctions,
|
||||
run.Items,
|
||||
slotTrace
|
||||
@@ -356,7 +342,8 @@ public static class SchedulePlanner
|
||||
{
|
||||
SlotBlockMode.Count => placed < Math.Max(1, slot.BlockValue),
|
||||
// Последняя единица входит целиком: обрезать видеофайл нельзя.
|
||||
SlotBlockMode.Duration => accumulated < TimeSpan.FromMinutes(Math.Max(1, slot.BlockValue)),
|
||||
SlotBlockMode.Duration => accumulated
|
||||
< TimeSpan.FromMinutes(Math.Max(1, slot.BlockValue)),
|
||||
_ => cursor + unit.Duration <= budgetEnd,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -58,7 +58,12 @@ public class ScheduleTemplate
|
||||
};
|
||||
// Фоновый слой заводится сразу: без него первая же дыра в сетке осталась бы нечем закрыть.
|
||||
template._layers.Add(
|
||||
GridLayer.Create(template.Id, BackgroundLayerName, GridLayer.BackgroundPriority, isBackground: true)
|
||||
GridLayer.Create(
|
||||
template.Id,
|
||||
BackgroundLayerName,
|
||||
GridLayer.BackgroundPriority,
|
||||
isBackground: true
|
||||
)
|
||||
);
|
||||
return template;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user