add health check for empty classic schedules (#2796)

This commit is contained in:
Jason Dove
2026-01-23 15:47:48 -06:00
committed by GitHub
parent f96be8f99f
commit 1754e7d5fb
5 changed files with 57 additions and 0 deletions
+1
View File
@@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- This is most often seen with VAAPI acceleration (radeonsi or i965 drivers)
- Add API endpoint to clean artwork cache folder (on demand)
- POST `/api/maintenance/clean_artwork`
- Add health check to warn about unsupported empty (classic) schedules
### Changed
- Disable automatic artwork database cleanup
@@ -0,0 +1,5 @@
namespace ErsatzTV.Core.Health.Checks;
public interface IEmptyScheduleHealthCheck : IHealthCheck
{
}
@@ -0,0 +1,48 @@
using ErsatzTV.Core.Health;
using ErsatzTV.Core.Health.Checks;
using ErsatzTV.Infrastructure.Data;
using Microsoft.EntityFrameworkCore;
namespace ErsatzTV.Infrastructure.Health.Checks;
public class EmptyScheduleHealthCheck(IDbContextFactory<TvContext> dbContextFactory) : BaseHealthCheck, IEmptyScheduleHealthCheck
{
public override string Title => "Empty Schedule";
public async Task<HealthCheckResult> Check(CancellationToken cancellationToken)
{
await using TvContext dbContext = await dbContextFactory.CreateDbContextAsync(cancellationToken);
List<int> scheduleIdsWithPlayouts = await dbContext.ProgramSchedules
.TagWithCallSite()
.AsNoTracking()
.Where(s => s.Playouts.Count > 0 && s.Items.Count == 0)
.Select(ps => ps.Id)
.ToListAsync(cancellationToken);
List<int> alternateScheduleIds = await dbContext.ProgramScheduleAlternates
.TagWithCallSite()
.AsNoTracking()
.Where(s => s.ProgramSchedule.Items.Count == 0)
.Select(s => s.ProgramScheduleId)
.ToListAsync(cancellationToken);
var ids = scheduleIdsWithPlayouts.Union(alternateScheduleIds).ToHashSet();
if (ids.Count > 0)
{
List<string> names = await dbContext.ProgramSchedules
.TagWithCallSite()
.AsNoTracking()
.Where(s => ids.Contains(s.Id))
.Select(s => s.Name)
.ToListAsync(cancellationToken);
return WarningResult(
$"There are {names.Count} empty schedules in use, which are NOT supported and WILL cause errors, including: {string.Join(", ", names.OrderBy(identity))}",
$"There are {names.Count} empty schedules in use, which are NOT supported and WILL cause errors");
}
return OkResult();
}
}
@@ -29,6 +29,7 @@ public class HealthCheckService : IHealthCheckService
IErrorReportsHealthCheck errorReportsHealthCheck,
IUnifiedDockerHealthCheck unifiedDockerHealthCheck,
IDowngradeHealthCheck downgradeHealthCheck,
IEmptyScheduleHealthCheck emptyScheduleHealthCheck,
IMemoryCache memoryCache,
IMediator mediator,
ILogger<HealthCheckService> logger)
@@ -49,6 +50,7 @@ public class HealthCheckService : IHealthCheckService
zeroDurationHealthCheck,
fileNotFoundHealthCheck,
unavailableHealthCheck,
emptyScheduleHealthCheck,
vaapiDriverHealthCheck,
errorReportsHealthCheck
];
+1
View File
@@ -772,6 +772,7 @@ public class Startup
services.AddScoped<IErrorReportsHealthCheck, ErrorReportsHealthCheck>();
services.AddScoped<IUnifiedDockerHealthCheck, UnifiedDockerHealthCheck>();
services.AddScoped<IDowngradeHealthCheck, DowngradeHealthCheck>();
services.AddScoped<IEmptyScheduleHealthCheck, EmptyScheduleHealthCheck>();
services.AddScoped<IHealthCheckService, HealthCheckService>();
services.AddScoped<IChannelRepository, ChannelRepository>();