Mediabibliotheek: module Media met eigen tabellen en geverifieerde kopie van de Hero-foto's (fase 1 van de migratie, standaard uit)
Continuous Integration / config-sls (pull_request) Successful in 10s
Continuous Integration / config-asf (pull_request) Successful in 7s
Continuous Integration / changes (pull_request) Successful in 20s
Continuous Integration / compile-sites (pull_request) Canceled after 0s
Continuous Integration / backend-test (pull_request) Canceled after 0s
Continuous Integration / vulnerability-scan (pull_request) Canceled after 0s
Continuous Integration / frontend-build (pull_request) Canceled after 0s
Continuous Integration / frontend-test (pull_request) Canceled after 0s
Continuous Integration / frontend-prepare (pull_request) Canceled after 27s
Continuous Integration / frontend-lint (pull_request) Canceled after 0s
Continuous Integration / publish-sls-test (pull_request) Canceled after 0s
Continuous Integration / publish-sls-production (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-test (pull_request) Canceled after 0s
Continuous Integration / deploy-sls-production (pull_request) Canceled after 0s
Continuous Integration / publish-asf-test (pull_request) Canceled after 0s
Continuous Integration / deploy-asf-test (pull_request) Canceled after 0s
Continuous Integration / smoke-sls-test (pull_request) Canceled after 0s
Continuous Integration / smoke-asf-test (pull_request) Canceled after 0s
Continuous Integration / backend-build (pull_request) Canceled after 54s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 15:38:40 +01:00
co-authored by Claude Sonnet 5.5
parent fc9417f752
commit 150c156fd7
25 changed files with 1304 additions and 8 deletions
@@ -0,0 +1,63 @@
using SlpModularCms.Core.Media.Library;
using SlpModularCms.Modules.Hero.Data.Entities;
using SlpModularCms.Modules.Hero.Repositories;
namespace SlpModularCms.Modules.Hero.Services;
/// <summary>
/// Offers the hero's photos (also those in the trash) and slides to the media library's copy, with the same ids, hashes and
/// set hashes the hero uses. Read-only: the hero's tables are never changed by the copy.
/// </summary>
public class HeroMediaMigrationSource(IHeroRepository repository) : IMediaMigrationSource
{
public string Module => HeroMapping.Area;
public async Task<IReadOnlyList<MediaAssetSnapshot>> ListAssetsAsync(CancellationToken cancellationToken)
=> (await repository.GetAllImagesIncludingTrashedReadOnlyAsync(cancellationToken)).Select(ToSnapshot).ToList();
public async Task<IReadOnlyList<MediaUseSnapshot>> ListUsesAsync(CancellationToken cancellationToken)
{
var images = (await repository.GetAllImagesIncludingTrashedReadOnlyAsync(cancellationToken)).ToDictionary(i => i.Id);
var slides = await repository.GetAllSlidesReadOnlyAsync(cancellationToken);
var uses = new List<MediaUseSnapshot>();
foreach (var hero in slides.GroupBy(s => s.HeroId))
{
var ordered = hero.OrderBy(s => s.SortOrder).ThenBy(s => s.Id).ToList();
for (var index = 0; index < ordered.Count; index++)
{
var slide = ordered[index];
var setHash = images.TryGetValue(slide.ImageId, out var image) ? image.SetHash : string.Empty;
uses.Add(new MediaUseSnapshot(slide.Id, slide.ImageId, Module, HeroMediaUsageProvider.SlideKind, index + 1, slide.IsActive, setHash));
}
}
return uses;
}
private MediaAssetSnapshot ToSnapshot(HeroImage i)
=> new(
i.Id,
Module,
i.OriginalSha256,
i.OriginalKey,
i.SourceFormat,
i.Width,
i.Height,
i.Bytes,
i.FocusX,
i.FocusY,
i.Zoom,
i.SetHash,
[Crop("wide", i), Crop("tall", i)],
i.CreatedAt,
i.CreatedByUserId,
i.OriginalFileName,
i.LastUsedAt,
i.DeletedAt);
private static MediaCropSnapshot Crop(string ratio, HeroImage image)
{
var focus = image.FocusFor(ratio);
return new MediaCropSnapshot(ratio, focus.X, focus.Y, focus.Zoom);
}
}