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:
@@ -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));
|
||||
|
||||
@@ -21,13 +21,19 @@ public class Image
|
||||
|
||||
private Image() { }
|
||||
|
||||
public static Image Create(ImageCategory category, string fileExtension, string? originalFileName) =>
|
||||
public static Image Create(
|
||||
ImageCategory category,
|
||||
string fileExtension,
|
||||
string? originalFileName
|
||||
) =>
|
||||
new()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Category = category,
|
||||
FileExtension = Normalize(fileExtension),
|
||||
OriginalFileName = string.IsNullOrWhiteSpace(originalFileName) ? null : originalFileName.Trim(),
|
||||
OriginalFileName = string.IsNullOrWhiteSpace(originalFileName)
|
||||
? null
|
||||
: originalFileName.Trim(),
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
};
|
||||
|
||||
|
||||
@@ -44,7 +44,12 @@ public class ShowEpisode
|
||||
}
|
||||
|
||||
/// <summary>Применить метаданные серии (кадр — уже зарегистрирован в реестре — может быть null).</summary>
|
||||
public void ApplyMetadata(string? title, string? overview, Guid? stillImageId, DateOnly? airDate)
|
||||
public void ApplyMetadata(
|
||||
string? title,
|
||||
string? overview,
|
||||
Guid? stillImageId,
|
||||
DateOnly? airDate
|
||||
)
|
||||
{
|
||||
Title = title;
|
||||
Overview = overview;
|
||||
|
||||
@@ -12,8 +12,7 @@ public class AppSetting
|
||||
|
||||
private AppSetting() { }
|
||||
|
||||
public static AppSetting Create(string key, string value) =>
|
||||
new() { Key = key, Value = value };
|
||||
public static AppSetting Create(string key, string value) => new() { Key = key, Value = value };
|
||||
|
||||
public void SetValue(string value) => Value = value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user