Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (push) Has been skipped
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (push) Has been skipped
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (push) Successful in 15m30s
Build ErsatzTV Image / Functional E2E (curl contracts) (push) Successful in 15m48s
Build ErsatzTV Image / Build & test (.NET) (push) Successful in 7m32s
Build ErsatzTV Image / Build & push image (amd64) (push) Has been cancelled
Closes #415. Server-derived health object on the channel list + detail DTOs (built-timeline detection, kind-agnostic across all 5 PlayoutScheduleKind; assessable gate keyed to the owning channel's mode), single "Problems" SPA filter with per-fault badges. Supersedes #72's api.channel-health-signal decision. Co-authored-by: Timothy <timothy.look@gmail.com> Co-committed-by: Timothy <timothy.look@gmail.com>
28 lines
1.1 KiB
C#
28 lines
1.1 KiB
C#
using ErsatzTV.Core.Api.Channels;
|
|
using ErsatzTV.Core.Domain;
|
|
using ErsatzTV.Core.Interfaces.Repositories;
|
|
using static ErsatzTV.Application.Channels.Mapper;
|
|
|
|
namespace ErsatzTV.Application.Channels;
|
|
|
|
public class GetChannelByIdForApiHandler(IChannelRepository channelRepository)
|
|
: IRequestHandler<GetChannelByIdForApi, Option<ChannelDetailResponseModel>>
|
|
{
|
|
public async Task<Option<ChannelDetailResponseModel>> Handle(
|
|
GetChannelByIdForApi request,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
Option<Channel> maybeChannel = await channelRepository.GetChannel(request.Id);
|
|
|
|
foreach (Channel channel in maybeChannel)
|
|
{
|
|
var playoutIds = ContributingPlayouts(channel).Select(p => p.Id).Distinct().ToList();
|
|
Dictionary<int, PlayoutUpcoming> upcoming =
|
|
await channelRepository.GetPlayoutUpcomingHealth(playoutIds, DateTime.UtcNow, cancellationToken);
|
|
return ProjectToDetailResponseModel(channel, GetPlayoutsCount(channel), upcoming);
|
|
}
|
|
|
|
return Option<ChannelDetailResponseModel>.None;
|
|
}
|
|
}
|