mirror of https://github.com/ErsatzTV/ErsatzTV.git
Browse Source
* check for overlapping playout items * tweak block filler builder * fix overlapping block playout items * update changelog * minor cleanuppull/2303/head
19 changed files with 12718 additions and 66 deletions
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
namespace ErsatzTV.Application.Playouts; |
||||
|
||||
public record CheckForOverlappingPlayoutItems(int PlayoutId) : IRequest, IBackgroundServiceRequest; |
||||
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
using ErsatzTV.Infrastructure.Data; |
||||
using Microsoft.EntityFrameworkCore; |
||||
using Microsoft.Extensions.Logging; |
||||
|
||||
namespace ErsatzTV.Application.Playouts; |
||||
|
||||
public class CheckForOverlappingPlayoutItemsHandler( |
||||
IDbContextFactory<TvContext> dbContextFactory, |
||||
ILogger<CheckForOverlappingPlayoutItemsHandler> logger) |
||||
: IRequestHandler<CheckForOverlappingPlayoutItems> |
||||
{ |
||||
public async Task Handle(CheckForOverlappingPlayoutItems request, CancellationToken cancellationToken) |
||||
{ |
||||
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken); |
||||
|
||||
bool hasConflict = await dbContext.PlayoutItems |
||||
.Where(pi => pi.PlayoutId == request.PlayoutId) |
||||
.AnyAsync(a => dbContext.PlayoutItems |
||||
.Any(b => |
||||
a.Id < b.Id && |
||||
a.Start < b.Finish && |
||||
a.Finish > b.Start), |
||||
cancellationToken); |
||||
|
||||
if (hasConflict) |
||||
{ |
||||
var maybeChannel = await dbContext.Channels |
||||
.AsNoTracking() |
||||
.Where(c => c.Playouts.Any(p => p.Id == request.PlayoutId)) |
||||
.FirstOrDefaultAsync(cancellationToken) |
||||
.Map(Optional); |
||||
|
||||
foreach (var channel in maybeChannel) |
||||
{ |
||||
logger.LogWarning( |
||||
"Playout for channel {ChannelName} has overlapping playout items; this may be a bug.", |
||||
channel.Name); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
||||
#nullable disable |
||||
|
||||
namespace ErsatzTV.Infrastructure.MySql.Migrations |
||||
{ |
||||
/// <inheritdoc />
|
||||
public partial class Add_PlayoutItemStartFinishIndex : Migration |
||||
{ |
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.CreateIndex( |
||||
name: "IX_PlayoutItem_Start_Finish", |
||||
table: "PlayoutItem", |
||||
columns: new[] { "Start", "Finish" }); |
||||
} |
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.DropIndex( |
||||
name: "IX_PlayoutItem_Start_Finish", |
||||
table: "PlayoutItem"); |
||||
} |
||||
} |
||||
} |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
||||
#nullable disable |
||||
|
||||
namespace ErsatzTV.Infrastructure.Sqlite.Migrations |
||||
{ |
||||
/// <inheritdoc />
|
||||
public partial class Add_PlayoutItemStartFinishIndex : Migration |
||||
{ |
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.CreateIndex( |
||||
name: "IX_PlayoutItem_Start_Finish", |
||||
table: "PlayoutItem", |
||||
columns: new[] { "Start", "Finish" }); |
||||
} |
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.DropIndex( |
||||
name: "IX_PlayoutItem_Start_Finish", |
||||
table: "PlayoutItem"); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue