Enhance ScheduleEntryDto and related components to support franchise collection details
Updated ScheduleEntryDto to include properties for collection part, total parts, and collection name, allowing for better representation of franchise information. Modified GetChannelScheduleQueryHandler to populate these new fields based on collection data. Adjusted SchedulePreview component to prioritize collection part display over episode information. Enhanced localization strings to support new collection-related terms in both English and Russian.
This commit is contained in:
+51
-1
@@ -82,6 +82,33 @@ public sealed class GetChannelScheduleQueryHandler(IAppDbContext dbContext)
|
||||
.Select(a => new { a.Id, a.OriginalFileName })
|
||||
.ToDictionaryAsync(a => a.Id, a => a.OriginalFileName, cancellationToken);
|
||||
|
||||
// Франшизы записей: у фильма серия всегда одна, и «Серия 1» в расписании — пустая метка.
|
||||
// Осмысленно другое — какой частью коллекции он шёл.
|
||||
var collectionIds = entries
|
||||
.Where(e => e.CollectionId != null)
|
||||
.Select(e => e.CollectionId!.Value)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
var collectionParts =
|
||||
collectionIds.Count == 0
|
||||
? []
|
||||
: await (
|
||||
from item in dbContext.CollectionItems.AsNoTracking()
|
||||
join collection in dbContext.Collections.AsNoTracking()
|
||||
on item.CollectionId equals collection.Id
|
||||
where collectionIds.Contains(item.CollectionId)
|
||||
select new
|
||||
{
|
||||
item.CollectionId,
|
||||
item.ShowId,
|
||||
item.Position,
|
||||
collection.Name,
|
||||
}
|
||||
).ToListAsync(cancellationToken);
|
||||
var partsByCollection = collectionParts
|
||||
.GroupBy(p => p.CollectionId)
|
||||
.ToDictionary(g => g.Key, g => g.OrderBy(p => p.Position).ToList());
|
||||
|
||||
var dtos = new List<ScheduleEntryDto>(entries.Count);
|
||||
foreach (var e in entries)
|
||||
{
|
||||
@@ -93,6 +120,26 @@ public sealed class GetChannelScheduleQueryHandler(IAppDbContext dbContext)
|
||||
bumperText = BumperText(bumper.RenderedLinesJson);
|
||||
}
|
||||
|
||||
// Номер части ищем по позиции шоу в коллекции, а не по индексу записи: франшизу могли
|
||||
// переупорядочить, и «часть 2» обязана означать вторую в текущем составе.
|
||||
int? part = null;
|
||||
int? parts = null;
|
||||
string? collectionName = null;
|
||||
if (
|
||||
e.CollectionId is { } collectionId
|
||||
&& e.ShowId is { } showId
|
||||
&& partsByCollection.TryGetValue(collectionId, out var ordered)
|
||||
)
|
||||
{
|
||||
var at = ordered.FindIndex(p => p.ShowId == showId);
|
||||
if (at >= 0)
|
||||
{
|
||||
part = at + 1;
|
||||
parts = ordered.Count;
|
||||
collectionName = ordered[0].Name;
|
||||
}
|
||||
}
|
||||
|
||||
dtos.Add(
|
||||
new ScheduleEntryDto(
|
||||
e.Id,
|
||||
@@ -107,7 +154,10 @@ public sealed class GetChannelScheduleQueryHandler(IAppDbContext dbContext)
|
||||
? EpisodeName.ParseLabel(name)
|
||||
: null,
|
||||
bumperName,
|
||||
bumperText
|
||||
bumperText,
|
||||
part,
|
||||
parts,
|
||||
collectionName
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,5 +14,12 @@ public sealed record ScheduleEntryDto(
|
||||
string? SeasonEpisode,
|
||||
// Для заставок (Kind == Bumper): имя подблока и его текст — для метки в админ-расписании.
|
||||
string? BumperName = null,
|
||||
string? BumperText = null
|
||||
string? BumperText = null,
|
||||
/// <summary>
|
||||
/// Какой частью франшизы шла запись и сколько их всего. У фильма серия всегда одна, и «Серия 1»
|
||||
/// в расписании ничего не значит; «часть 3 из 3» — значит.
|
||||
/// </summary>
|
||||
int? CollectionPart = null,
|
||||
int? CollectionParts = null,
|
||||
string? CollectionName = null
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user