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>
25 lines
1.0 KiB
C#
25 lines
1.0 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 GetAllChannelsForApiHandler(IChannelRepository channelRepository)
|
|
: IRequestHandler<GetAllChannelsForApi, List<ChannelResponseModel>>
|
|
{
|
|
public async Task<List<ChannelResponseModel>> Handle(
|
|
GetAllChannelsForApi request,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
List<Channel> channels = Optional(await channelRepository.GetAll(cancellationToken)).Flatten().ToList();
|
|
var playoutIds = channels
|
|
.SelectMany(c => ContributingPlayouts(c).Select(p => p.Id))
|
|
.Distinct()
|
|
.ToList();
|
|
Dictionary<int, PlayoutUpcoming> upcoming =
|
|
await channelRepository.GetPlayoutUpcomingHealth(playoutIds, DateTime.UtcNow, cancellationToken);
|
|
return channels.Map(c => ProjectToResponseModel(c, GetPlayoutsCount(c), upcoming)).ToList();
|
|
}
|
|
}
|