feat(backend): expose the first cover track ids of playlists and albums

This commit is contained in:
2026-07-21 18:13:18 +02:00
parent 496a5f4a0b
commit 78cc2f7248
11 changed files with 125 additions and 29 deletions
@@ -14,16 +14,24 @@ namespace Musify.Application.PlayLists
{
public async ValueTask<ErrorOr<PlayListApplicationResponse>> Handle(GetPlayListByIdQuery request, CancellationToken cancellationToken)
{
var playList = await database.PlayLists
var entry = await database.PlayLists
.AsNoTracking()
.Where(p => p.Id == request.Id)
.Select(p => PlayListApplicationResponse.FromEntity(p))
.Select(p => new
{
PlayList = p,
CoverTrackIds = p.PlayListTracks
.OrderBy(plt => plt.Position)
.Take(PlayListApplicationResponse.CoverTrackCount)
.Select(plt => plt.TrackId)
.ToList()
})
.SingleOrDefaultAsync(cancellationToken);
if (playList is null)
if (entry is null)
return Error.NotFound();
return playList;
return PlayListApplicationResponse.FromEntity(entry.PlayList, entry.CoverTrackIds);
}
}
}