feat(backend): expose track duration and listen count in track response

This commit is contained in:
2026-07-14 13:54:12 +02:00
parent afac7d5dd5
commit 2e866075a2
3 changed files with 13 additions and 1 deletions
@@ -5,14 +5,20 @@ namespace Musify.Application.Tracks.Responses
public record TrackApplicationResponse(
Guid Id,
string Title,
int Duration,
int ListensCount,
DateTime CreatedAt,
DateTime UpdatedAt)
{
public static TrackApplicationResponse FromEntity(Track track)
{
var count = track.ListeningHistories.Count(x => x.TrackId == track.Id);
return new TrackApplicationResponse(
track.Id,
track.Title,
track.Duration,
count,
track.CreatedAt,
track.UpdatedAt);
}