Refactor various components to improve code clarity and maintainability. Update ListUsersQueryHandler to utilize UserListFilter for parameter handling. Refactor BumperSpecFactory and related classes to encapsulate input parameters into dedicated records, enhancing readability. Adjust MediaAsset and Slot classes to streamline content updates with new content models. Improve BumperRenderBackgroundService and MediaProcessingBackgroundService to use MediaReadyInfo for asset readiness, ensuring consistent parameter management across the application.
ci / build-backend (push) Successful in 1m55s
ci / build-frontend (push) Successful in 45s
ci / tests (push) Successful in 2m33s
ci / sonar (push) Successful in 6m28s

This commit is contained in:
Leonid Pershin
2026-07-27 00:56:04 +03:00
parent 419aff54fa
commit 19fa23b619
47 changed files with 556 additions and 423 deletions
@@ -21,7 +21,9 @@ public class MediaStatsTests
{
var a = Pending(name);
a.MarkProcessing();
a.MarkReady(TimeSpan.FromMinutes(20), 2, 600, 1920, 1080, "h264", "aac", "assets/x");
a.MarkReady(
new MediaReadyInfo(TimeSpan.FromMinutes(20), 2, 600, 1920, 1080, "h264", "aac", "assets/x")
);
return a;
}
@@ -28,7 +28,12 @@ public class BumperTextVariantTests
{
var v = NewVariant();
v.Update("Name", BumperTextKind.Free, "NOW", "NEXT", "l1", "l2", BumperTrigger.Both, -5);
v.Update(
"Name",
new BumperTextContent(BumperTextKind.Free, "NOW", "NEXT", "l1", "l2"),
BumperTrigger.Both,
-5
);
Assert.Equal("Name", v.Name);
Assert.Equal(BumperTextKind.Free, v.Kind);
@@ -48,7 +53,7 @@ public class BumperTextVariantTests
public void Matches_FollowsTrigger(BumperTrigger trigger, bool isShowChange, bool expected)
{
var v = NewVariant();
v.Update("n", BumperTextKind.NowNext, "a", "b", "", "", trigger, 1);
v.Update("n", new BumperTextContent(BumperTextKind.NowNext, "a", "b", "", ""), trigger, 1);
Assert.Equal(expected, v.Matches(isShowChange));
}
@@ -35,14 +35,16 @@ public class MediaAssetTests
var asset = MediaAsset.Register("a.mp4", ".mp4", MediaSource.Upload);
asset.MarkReady(
TimeSpan.FromSeconds(120),
segmentSeconds: 2,
segmentCount: 60,
width: 1920,
height: 1080,
videoCodec: "h264",
audioCodec: "aac",
relativePath: "assets/abc"
new MediaReadyInfo(
TimeSpan.FromSeconds(120),
SegmentSeconds: 2,
SegmentCount: 60,
Width: 1920,
Height: 1080,
VideoCodec: "h264",
AudioCodec: "aac",
RelativePath: "assets/abc"
)
);
Assert.Equal(MediaAssetStatus.Ready, asset.Status);
@@ -64,7 +66,9 @@ public class MediaAssetTests
Assert.NotNull(asset.ProcessingStartedAt);
Assert.Null(asset.ProcessingDuration);
asset.MarkReady(TimeSpan.FromSeconds(120), 2, 60, 1920, 1080, "h264", "aac", "assets/abc");
asset.MarkReady(
new MediaReadyInfo(TimeSpan.FromSeconds(120), 2, 60, 1920, 1080, "h264", "aac", "assets/abc")
);
Assert.NotNull(asset.ProcessingDuration);
Assert.True(asset.ProcessingDuration >= TimeSpan.Zero);
@@ -75,7 +79,9 @@ public class MediaAssetTests
{
var asset = MediaAsset.Register("a.mp4", ".mp4", MediaSource.Upload);
asset.MarkReady(TimeSpan.FromSeconds(120), 2, 60, 1920, 1080, "h264", "aac", "assets/abc");
asset.MarkReady(
new MediaReadyInfo(TimeSpan.FromSeconds(120), 2, 60, 1920, 1080, "h264", "aac", "assets/abc")
);
Assert.Null(asset.ProcessingDuration);
}
@@ -113,25 +113,29 @@ public class GridLayerOverlapTests
var layer = NewLayer();
var slot = layer.AddSlot("Кино", new TimeOnly(20, 0), 90);
slot.UpdateContent(
"Кино",
SlotKind.Content,
Guid.NewGuid(),
"{\"type\":\"sequential\"}",
null,
SlotBlockMode.Count,
1,
OverflowPolicy.ContinueNext
new SlotContent(
"Кино",
SlotKind.Content,
Guid.NewGuid(),
"{\"type\":\"sequential\"}",
null,
SlotBlockMode.Count,
1,
OverflowPolicy.ContinueNext
)
);
slot.UpdateContent(
"Конец вещания",
SlotKind.SignOff,
Guid.NewGuid(),
"{\"type\":\"sequential\"}",
null,
SlotBlockMode.FillSlot,
1,
OverflowPolicy.ContinueNext
new SlotContent(
"Конец вещания",
SlotKind.SignOff,
Guid.NewGuid(),
"{\"type\":\"sequential\"}",
null,
SlotBlockMode.FillSlot,
1,
OverflowPolicy.ContinueNext
)
);
// Иначе генератор прочитал бы настройки, оставшиеся от прежнего типа слота.
@@ -249,14 +249,16 @@ public sealed class GridScheduleGeneratorIntegrationTests(PostgresFixture fixtur
var layer = template.AddLayer("Базовый", 10);
var slot = layer.AddSlot("Дневной блок", new TimeOnly(6, 0), 24 * 60);
slot.UpdateContent(
slot.Title,
SlotKind.Content,
group.Id,
new SlotStrategy(SlotStrategyType.Sequential).ToJson(),
null,
SlotBlockMode.FillSlot,
1,
OverflowPolicy.ContinueNext
new SlotContent(
slot.Title,
SlotKind.Content,
group.Id,
new SlotStrategy(SlotStrategyType.Sequential).ToJson(),
null,
SlotBlockMode.FillSlot,
1,
OverflowPolicy.ContinueNext
)
);
channel.SetTemplate(template.Id);
// Правка правил помечает шаблон изменённым — воспроизводим состояние «есть что применить».
@@ -275,14 +277,16 @@ public sealed class GridScheduleGeneratorIntegrationTests(PostgresFixture fixtur
var asset = MediaAsset.Register(fileName, ".mkv", MediaSource.Upload);
asset.MarkProcessing();
asset.MarkReady(
duration,
segmentSeconds: 2,
segmentCount: (int)(duration.TotalSeconds / 2),
width: 1920,
height: 1080,
videoCodec: "h264",
audioCodec: "aac",
relativePath: $"segments/{asset.Id}"
new MediaReadyInfo(
duration,
SegmentSeconds: 2,
SegmentCount: (int)(duration.TotalSeconds / 2),
Width: 1920,
Height: 1080,
VideoCodec: "h264",
AudioCodec: "aac",
RelativePath: $"segments/{asset.Id}"
)
);
db.MediaAssets.Add(asset);
return asset;
@@ -150,15 +150,17 @@ public sealed class TemplateOperationsIntegrationTests(PostgresFixture fixture)
var layer = sourceTemplate.AddLayer("Прайм", 10);
var slot = layer.AddSlot("Вечернее кино", new TimeOnly(20, 0), 120);
slot.UpdateContent(
slot.Title,
SlotKind.Content,
group.Id,
new SlotStrategy(SlotStrategyType.Sequential).ToJson(),
null,
SlotBlockMode.FillSlot,
1,
OverflowPolicy.ContinueNext,
junctionAfterId: junction.Id
new SlotContent(
slot.Title,
SlotKind.Content,
group.Id,
new SlotStrategy(SlotStrategyType.Sequential).ToJson(),
null,
SlotBlockMode.FillSlot,
1,
OverflowPolicy.ContinueNext,
JunctionAfterId: junction.Id
)
);
sourceTemplate.SetDefaultJunction(junction.Id);
source.SetTemplate(sourceTemplate.Id);
@@ -52,7 +52,9 @@ public sealed class TransactionIntegrationTests(PostgresFixture fixture)
var channel = Channel.Create("c", $"c-{Guid.NewGuid():N}", DateTimeOffset.UnixEpoch);
var show = Show.Create("Show", ShowKind.Series);
var asset = MediaAsset.Register("ep.mkv", ".mkv", MediaSource.Upload);
asset.MarkReady(TimeSpan.FromMinutes(20), 2, 600, 1920, 1080, "h264", "aac", "assets/x");
asset.MarkReady(
new MediaReadyInfo(TimeSpan.FromMinutes(20), 2, 600, 1920, 1080, "h264", "aac", "assets/x")
);
show.AddEpisode(asset.Id);
var entry = ScheduleEntry.Program(
channel.Id,