Fase 2 stap B (backend): uitsnede per slide met eigen set, renderer, mapping en endpoints
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -48,6 +48,15 @@ public interface IHeroRepository
|
||||
|
||||
Task<IReadOnlyList<HeroImage>> GetImagesNeedingRenderAsync(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>One slide with its photo, tracked (a new crop for the slide); null when there is none or its photo is in the trash.</summary>
|
||||
Task<HeroSlide?> GetSlideAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>The slide as stored right now, with its photo, not tracked.</summary>
|
||||
Task<HeroSlide?> GetSlideFreshAsync(Guid id, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Slides with a crop of their own whose set is missing or does not match that crop, in hero order (tracked).</summary>
|
||||
Task<IReadOnlyList<HeroSlide>> GetSlidesNeedingRenderAsync(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>Images with a complete set made before the full-frame preview existed (tracked).</summary>
|
||||
Task<IReadOnlyList<HeroImage>> GetImagesNeedingPreviewAsync(CancellationToken cancellationToken);
|
||||
|
||||
@@ -133,6 +142,18 @@ public class HeroRepository(HeroDbContext context) : IHeroRepository
|
||||
public async Task<IReadOnlyList<HeroImage>> GetImagesNeedingPreviewAsync(CancellationToken cancellationToken)
|
||||
=> (await context.HeroImages.Where(i => i.DeletedAt == null).ToListAsync(cancellationToken)).Where(HeroMapping.NeedsPreview).OrderBy(i => i.CreatedAt).ToList();
|
||||
|
||||
public Task<HeroSlide?> GetSlideAsync(Guid id, CancellationToken cancellationToken)
|
||||
=> context.HeroSlides.Include(s => s.Image).FirstOrDefaultAsync(s => s.Id == id && s.Image != null && s.Image.DeletedAt == null, cancellationToken);
|
||||
|
||||
public Task<HeroSlide?> GetSlideFreshAsync(Guid id, CancellationToken cancellationToken)
|
||||
=> context.HeroSlides.AsNoTracking().Include(s => s.Image).FirstOrDefaultAsync(s => s.Id == id && s.Image != null && s.Image.DeletedAt == null, cancellationToken);
|
||||
|
||||
public async Task<IReadOnlyList<HeroSlide>> GetSlidesNeedingRenderAsync(CancellationToken cancellationToken)
|
||||
=> (await context.HeroSlides.Include(s => s.Image).Where(s => s.FocusX != null && s.FocusY != null).ToListAsync(cancellationToken))
|
||||
.Where(s => s.Image is { DeletedAt: null } && HeroMapping.SlideNeedsRender(s))
|
||||
.OrderBy(s => s.SortOrder)
|
||||
.ToList();
|
||||
|
||||
public Task<HeroImage?> GetImageFreshAsync(Guid id, CancellationToken cancellationToken)
|
||||
=> context.HeroImages.AsNoTracking().FirstOrDefaultAsync(i => i.Id == id && i.DeletedAt == null, cancellationToken);
|
||||
|
||||
@@ -154,7 +175,12 @@ public class HeroRepository(HeroDbContext context) : IHeroRepository
|
||||
}
|
||||
|
||||
public async Task<HashSet<string>> GetReferencedSetHashesAsync(CancellationToken cancellationToken)
|
||||
=> (await context.HeroImages.Select(i => i.SetHash).ToListAsync(cancellationToken)).ToHashSet(StringComparer.Ordinal);
|
||||
{
|
||||
// The sets of the photos and the own sets of slides with a crop of their own.
|
||||
var sets = (await context.HeroImages.Select(i => i.SetHash).ToListAsync(cancellationToken)).ToHashSet(StringComparer.Ordinal);
|
||||
sets.UnionWith((await context.HeroSlides.Select(s => s.SetHash).ToListAsync(cancellationToken)).Where(h => !string.IsNullOrEmpty(h))!);
|
||||
return sets;
|
||||
}
|
||||
|
||||
public async Task<HashSet<string>> GetReferencedOriginalKeysAsync(CancellationToken cancellationToken)
|
||||
=> (await context.HeroImages.Select(i => i.OriginalKey).ToListAsync(cancellationToken)).ToHashSet(StringComparer.Ordinal);
|
||||
|
||||
Reference in New Issue
Block a user