Add InterstitialGroups service and enhance SlotWriter and related components for interstitial handling
ci / build-backend (push) Successful in 1m18s
ci / build-frontend (push) Successful in 43s
ci / tests (push) Successful in 3m38s
ci / sonar (push) Successful in 3m38s

Introduced the InterstitialGroups service to manage interstitial group logic, preventing their inclusion in slots and fallback groups. Updated the SlotWriter class to utilize this service, ensuring proper validation during slot creation and updates. Enhanced error handling for interstitial groups in the ImportGridCommandHandler and UpdateTemplateCommandHandler, providing warnings instead of failures when interstitials are detected. Updated related tests to verify the correct behavior of these changes, ensuring robust handling of interstitials in the scheduling process.
This commit is contained in:
Leonid Pershin
2026-07-30 12:48:51 +03:00
parent 398b60facc
commit 926a20020f
15 changed files with 370 additions and 39 deletions
@@ -87,7 +87,7 @@ public class TemplateEditingTests
private static async Task<Guid> AddSlotAsync(Fixture f, SlotInput input)
{
await using var db = f.Db.New();
var created = await new CreateSlotCommandHandler(new SlotWriter(db)).Handle(
var created = await new CreateSlotCommandHandler(GroupServices.Slots(db)).Handle(
new CreateSlotCommand(f.LayerId, input),
CancellationToken.None
);
@@ -116,7 +116,7 @@ public class TemplateEditingTests
var f = await SeedAsync();
await using var db = f.Db.New();
var result = await new CreateSlotCommandHandler(new SlotWriter(db)).Handle(
var result = await new CreateSlotCommandHandler(GroupServices.Slots(db)).Handle(
new CreateSlotCommand(Guid.NewGuid(), Input(groupId: f.GroupId)),
CancellationToken.None
);
@@ -151,7 +151,7 @@ public class TemplateEditingTests
var f = await SeedAsync();
await using var db = f.Db.New();
var result = await new CreateSlotCommandHandler(new SlotWriter(db)).Handle(
var result = await new CreateSlotCommandHandler(GroupServices.Slots(db)).Handle(
new CreateSlotCommand(f.LayerId, Input(groupId: null)),
CancellationToken.None
);
@@ -165,7 +165,7 @@ public class TemplateEditingTests
var f = await SeedAsync();
await using var db = f.Db.New();
var result = await new CreateSlotCommandHandler(new SlotWriter(db)).Handle(
var result = await new CreateSlotCommandHandler(GroupServices.Slots(db)).Handle(
new CreateSlotCommand(f.LayerId, Input(groupId: Guid.NewGuid())),
CancellationToken.None
);
@@ -179,7 +179,7 @@ public class TemplateEditingTests
var f = await SeedAsync();
await using var db = f.Db.New();
var result = await new CreateSlotCommandHandler(new SlotWriter(db)).Handle(
var result = await new CreateSlotCommandHandler(GroupServices.Slots(db)).Handle(
new CreateSlotCommand(f.LayerId, Input(kind: SlotKind.Repeat)),
CancellationToken.None
);
@@ -211,7 +211,7 @@ public class TemplateEditingTests
await AddSlotAsync(f, Input(groupId: f.GroupId));
await using var db = f.Db.New();
var result = await new CreateSlotCommandHandler(new SlotWriter(db)).Handle(
var result = await new CreateSlotCommandHandler(GroupServices.Slots(db)).Handle(
new CreateSlotCommand(
f.LayerId,
Input(title: "Второй", start: new TimeOnly(21, 0), groupId: f.GroupId)
@@ -228,7 +228,7 @@ public class TemplateEditingTests
var f = await SeedAsync();
await using var db = f.Db.New();
var result = await new UpdateSlotCommandHandler(new SlotWriter(db)).Handle(
var result = await new UpdateSlotCommandHandler(GroupServices.Slots(db)).Handle(
new UpdateSlotCommand(Guid.NewGuid(), Input(groupId: f.GroupId)),
CancellationToken.None
);
@@ -245,7 +245,7 @@ public class TemplateEditingTests
await using (var db = f.Db.New())
{
// Сдвиг внутрь собственного интервала: слот не должен пересечься сам с собой.
var result = await new UpdateSlotCommandHandler(new SlotWriter(db)).Handle(
var result = await new UpdateSlotCommandHandler(GroupServices.Slots(db)).Handle(
new UpdateSlotCommand(
slotId,
Input(title: "Ночное кино", start: new TimeOnly(21, 0), groupId: f.GroupId)
@@ -270,7 +270,7 @@ public class TemplateEditingTests
await using (var db = f.Db.New())
{
var missing = await new DeleteSlotCommandHandler(new SlotWriter(db)).Handle(
var missing = await new DeleteSlotCommandHandler(GroupServices.Slots(db)).Handle(
new DeleteSlotCommand(Guid.NewGuid()),
CancellationToken.None
);
@@ -279,7 +279,7 @@ public class TemplateEditingTests
await using (var db = f.Db.New())
{
var deleted = await new DeleteSlotCommandHandler(new SlotWriter(db)).Handle(
var deleted = await new DeleteSlotCommandHandler(GroupServices.Slots(db)).Handle(
new DeleteSlotCommand(slotId),
CancellationToken.None
);
@@ -407,7 +407,10 @@ public class TemplateEditingTests
var f = await SeedAsync();
await using var db = f.Db.New();
var result = await new UpdateTemplateCommandHandler(db).Handle(
var result = await new UpdateTemplateCommandHandler(
db,
GroupServices.Interstitials(db)
).Handle(
new UpdateTemplateCommand(Guid.NewGuid(), "Сетка", null, null, null),
CancellationToken.None
);
@@ -421,7 +424,10 @@ public class TemplateEditingTests
var f = await SeedAsync();
await using var db = f.Db.New();
var result = await new UpdateTemplateCommandHandler(db).Handle(
var result = await new UpdateTemplateCommandHandler(
db,
GroupServices.Interstitials(db)
).Handle(
new UpdateTemplateCommand(f.TemplateId, "Сетка", Guid.NewGuid(), null, null),
CancellationToken.None
);
@@ -447,7 +453,10 @@ public class TemplateEditingTests
await using (var db = f.Db.New())
{
var result = await new UpdateTemplateCommandHandler(db).Handle(
var result = await new UpdateTemplateCommandHandler(
db,
GroupServices.Interstitials(db)
).Handle(
new UpdateTemplateCommand(f.TemplateId, " Новая сетка ", f.GroupId, null, rules),
CancellationToken.None
);