Refactor code formatting and improve readability: standardize line breaks and indentation across various endpoint files, enhancing code clarity and maintainability. Update package version formatting in Directory.Packages.props for consistency.

This commit is contained in:
Leonid Pershin
2026-07-25 19:55:01 +03:00
parent 1f6fa6f1ae
commit f57b7503ed
122 changed files with 1856 additions and 892 deletions
@@ -131,7 +131,8 @@ public class Channel
/// <summary>Добавить блок заставки в конец списка. Возвращает созданный блок.</summary>
public BumperTemplate AddBumperTemplate(string name)
{
var nextPosition = _bumperTemplates.Count == 0 ? 0 : _bumperTemplates.Max(t => t.Position) + 1;
var nextPosition =
_bumperTemplates.Count == 0 ? 0 : _bumperTemplates.Max(t => t.Position) + 1;
var template = BumperTemplate.Create(Id, nextPosition, name);
_bumperTemplates.Add(template);
return template;
@@ -153,7 +154,8 @@ public class Channel
/// <summary>Планировщик двигает курсор ротации блоков заставок по мере вставки.</summary>
public void SetNextBumperIndex(int index) => NextBumperIndex = index;
public ChannelShow? FindShow(Guid channelShowId) => _shows.FirstOrDefault(s => s.Id == channelShowId);
public ChannelShow? FindShow(Guid channelShowId) =>
_shows.FirstOrDefault(s => s.Id == channelShowId);
public ChannelShow AddShow(Guid showId, int weight, BlockMode blockMode, int blockValue)
{
@@ -69,9 +69,11 @@ public class ChannelShow
{
PreferredWeightMultiplier = Math.Max(1, multiplier);
_preferredHours.Clear();
foreach (var (start, end) in windows
.Where(w => w.StartHour >= 0 && w.EndHour <= 24 && w.StartHour < w.EndHour)
.Distinct())
foreach (
var (start, end) in windows
.Where(w => w.StartHour >= 0 && w.EndHour <= 24 && w.StartHour < w.EndHour)
.Distinct()
)
{
_preferredHours.Add(ChannelShowHour.Create(Id, start, end));
}
@@ -62,7 +62,9 @@ public static class LiveWindowCalculator
LiveInput input
)
{
var entry = input.Entries.FirstOrDefault(e => segTime >= e.StartsAtUtc && segTime < e.EndsAtUtc);
var entry = input.Entries.FirstOrDefault(e =>
segTime >= e.StartsAtUtc && segTime < e.EndsAtUtc
);
if (entry is not null)
{
var local = (int)Math.Floor((segTime - entry.StartsAtUtc).TotalSeconds / seg);
@@ -72,7 +74,9 @@ public static class LiveWindowCalculator
if (input.Filler is { SegmentCount: > 0 } filler)
{
var local = (int)(((globalIndex % filler.SegmentCount) + filler.SegmentCount) % filler.SegmentCount);
var local = (int)(
((globalIndex % filler.SegmentCount) + filler.SegmentCount) % filler.SegmentCount
);
return (filler.AssetId, local);
}
@@ -57,7 +57,17 @@ public static class SchedulePlanner
if (RollChance(chance, random))
{
var bumperStart = cursor;
if (TryPlaceBumper(entries, bumper, prev, pick.ShowId, random, ref nextBumper, ref cursor))
if (
TryPlaceBumper(
entries,
bumper,
prev,
pick.ShowId,
random,
ref nextBumper,
ref cursor
)
)
lastBumperAt = bumperStart;
}
}
@@ -115,8 +125,10 @@ public static class SchedulePlanner
)
{
var isShowChange = fromShowId != toShowId;
var eligible = bumper.Variants
.Where(v => v.Duration > TimeSpan.Zero && MatchesTrigger(v.Trigger, isShowChange))
var eligible = bumper
.Variants.Where(v =>
v.Duration > TimeSpan.Zero && MatchesTrigger(v.Trigger, isShowChange)
)
.ToList();
if (eligible.Count == 0)
return false;
@@ -211,7 +223,10 @@ public static class SchedulePlanner
var overridden = new List<(PlannerShow, int)>();
foreach (var os in ovr.Shows)
{
if (!byShowId.TryGetValue(os.ShowId, out var show) || show.EpisodeAssetIds.Count == 0)
if (
!byShowId.TryGetValue(os.ShowId, out var show)
|| show.EpisodeAssetIds.Count == 0
)
continue;
var weight = ovr.Mode == OverrideMode.Exclusive ? 1 : os.Weight;
if (weight > 0)
@@ -224,8 +239,8 @@ public static class SchedulePlanner
}
var hour = moment.UtcDateTime.Hour;
return input.Shows
.Where(s => s.Weight > 0 && s.EpisodeAssetIds.Count > 0)
return input
.Shows.Where(s => s.Weight > 0 && s.EpisodeAssetIds.Count > 0)
.Select(s => (s, EffectiveWeight(s, hour)))
.ToList();
}
@@ -318,7 +333,9 @@ public static class SchedulePlanner
for (var i = 0; i < input.AdsPerBreak; i++)
{
var assetId = input.AdPool[((nextAd % input.AdPool.Count) + input.AdPool.Count) % input.AdPool.Count];
var assetId = input.AdPool[
((nextAd % input.AdPool.Count) + input.AdPool.Count) % input.AdPool.Count
];
nextAd++;
var end = cursor + DurationOf(assetId, input);
entries.Add(new PlannedEntry(assetId, ScheduleEntryKind.Ad, cursor, end, null, null));