Refactor code formatting and improve readability: standardize line breaks and indentation across various endpoint files, enhancing code clarity and maintainability. Update package version formatting in Directory.Packages.props for consistency.

This commit is contained in:
Leonid Pershin
2026-07-25 19:55:01 +03:00
parent 1f6fa6f1ae
commit f57b7503ed
122 changed files with 1856 additions and 892 deletions
@@ -21,9 +21,15 @@ public sealed class GetLivePlaylistQueryHandler(
CancellationToken cancellationToken
)
{
var channel = await dbContext.Channels.AsNoTracking()
var channel = await dbContext
.Channels.AsNoTracking()
.Where(c => c.Slug == query.Slug && c.IsEnabled)
.Select(c => new { c.Id, c.EpochUtc, c.FillerAssetId })
.Select(c => new
{
c.Id,
c.EpochUtc,
c.FillerAssetId,
})
.FirstOrDefaultAsync(cancellationToken);
if (channel is null)
return Result.Failure<LivePlaylistDto>(ChannelErrors.NotFound);
@@ -33,7 +39,8 @@ public sealed class GetLivePlaylistQueryHandler(
// Загружаем записи, пересекающиеся с окном (с небольшим запасом назад).
var windowStartTime = query.Now.AddSeconds(-(window + 2) * seg);
var rawEntries = await dbContext.ScheduleEntries.AsNoTracking()
var rawEntries = await dbContext
.ScheduleEntries.AsNoTracking()
.Where(e =>
e.ChannelId == channel.Id
&& e.StartsAtUtc < query.Now
@@ -52,7 +59,8 @@ public sealed class GetLivePlaylistQueryHandler(
if (channel.FillerAssetId is { } fillerId)
assetIds.Add(fillerId);
var segmentCounts = await dbContext.MediaAssets.AsNoTracking()
var segmentCounts = await dbContext
.MediaAssets.AsNoTracking()
.Where(a =>
assetIds.Contains(a.Id)
&& a.Status == MediaAssetStatus.Ready
@@ -72,7 +80,10 @@ public sealed class GetLivePlaylistQueryHandler(
.ToList();
LiveFiller? filler = null;
if (channel.FillerAssetId is { } fid && segmentCounts.TryGetValue(fid, out var fillerSegments))
if (
channel.FillerAssetId is { } fid
&& segmentCounts.TryGetValue(fid, out var fillerSegments)
)
filler = new LiveFiller(fid, fillerSegments);
var playlist = LiveWindowCalculator.Build(
@@ -82,8 +93,8 @@ public sealed class GetLivePlaylistQueryHandler(
var dto = new LivePlaylistDto(
playlist.MediaSequence,
playlist.TargetDuration,
playlist.Segments
.Select(s => new LiveSegmentDto(s.AssetId, s.LocalIndex, s.Discontinuity))
playlist
.Segments.Select(s => new LiveSegmentDto(s.AssetId, s.LocalIndex, s.Discontinuity))
.ToList()
);
return Result.Success(dto);
@@ -14,14 +14,16 @@ public sealed class GetPublicEpgQueryHandler(IAppDbContext dbContext)
CancellationToken cancellationToken
)
{
var channelId = await dbContext.Channels.AsNoTracking()
var channelId = await dbContext
.Channels.AsNoTracking()
.Where(c => c.Slug == query.Slug && c.IsEnabled)
.Select(c => (Guid?)c.Id)
.FirstOrDefaultAsync(cancellationToken);
if (channelId is null)
return Result.Failure<IReadOnlyList<PublicEpgEntryDto>>(ChannelErrors.NotFound);
var entries = await dbContext.ScheduleEntries.AsNoTracking()
var entries = await dbContext
.ScheduleEntries.AsNoTracking()
.Where(e =>
e.ChannelId == channelId
&& e.StartsAtUtc < query.ToUtc
@@ -38,15 +40,26 @@ public sealed class GetPublicEpgQueryHandler(IAppDbContext dbContext)
})
.ToListAsync(cancellationToken);
var showIds = entries.Where(e => e.ShowId != null).Select(e => e.ShowId!.Value).Distinct().ToList();
var shows = await dbContext.Shows.AsNoTracking()
var showIds = entries
.Where(e => e.ShowId != null)
.Select(e => e.ShowId!.Value)
.Distinct()
.ToList();
var shows = await dbContext
.Shows.AsNoTracking()
.Where(s => showIds.Contains(s.Id))
.Select(s => new { s.Id, s.Name, s.PosterImageId })
.Select(s => new
{
s.Id,
s.Name,
s.PosterImageId,
})
.ToDictionaryAsync(s => s.Id, cancellationToken);
// Метаданные серий: ключ — (шоу, ассет).
var assetIds = entries.Select(e => e.MediaAssetId).Distinct().ToList();
var episodes = await dbContext.Shows.AsNoTracking()
var episodes = await dbContext
.Shows.AsNoTracking()
.SelectMany(s => s.Episodes)
.Where(e => showIds.Contains(e.ShowId) && assetIds.Contains(e.MediaAssetId))
.Select(e => new
@@ -13,10 +13,16 @@ public sealed class ListPublicChannelsQueryHandler(IAppDbContext dbContext)
CancellationToken cancellationToken
)
{
var channels = await dbContext.Channels.AsNoTracking()
var channels = await dbContext
.Channels.AsNoTracking()
.Where(c => c.IsEnabled)
.OrderBy(c => c.Name)
.Select(c => new { c.Id, c.Slug, c.Name })
.Select(c => new
{
c.Id,
c.Slug,
c.Name,
})
.ToListAsync(cancellationToken);
if (channels.Count == 0)
return [];
@@ -25,7 +31,8 @@ public sealed class ListPublicChannelsQueryHandler(IAppDbContext dbContext)
var channelIds = channels.Select(c => c.Id).ToList();
// Что идёт прямо сейчас на каждом канале (программа) — для постера-обложки плитки.
var currentByChannel = await dbContext.ScheduleEntries.AsNoTracking()
var currentByChannel = await dbContext
.ScheduleEntries.AsNoTracking()
.Where(e =>
channelIds.Contains(e.ChannelId)
&& e.Kind == ScheduleEntryKind.Program
@@ -40,9 +47,15 @@ public sealed class ListPublicChannelsQueryHandler(IAppDbContext dbContext)
.ToDictionary(g => g.Key, g => g.First().ShowId);
var showIds = currentShowByChannel.Values.Distinct().ToList();
var shows = await dbContext.Shows.AsNoTracking()
var shows = await dbContext
.Shows.AsNoTracking()
.Where(s => showIds.Contains(s.Id))
.Select(s => new { s.Id, s.Name, s.PosterImageId })
.Select(s => new
{
s.Id,
s.Name,
s.PosterImageId,
})
.ToDictionaryAsync(s => s.Id, cancellationToken);
return channels