fix(backend): compute track listens count via SQL instead of an unloaded navigation

TrackApplicationResponse.FromEntity counted track.ListeningHistories,
but none of the queries that built a response ever Included it, so
the collection was always empty and listensCount was always 0. Each
query now projects the count as a correlated subquery before mapping
to the response.
This commit is contained in:
2026-07-15 16:09:54 +02:00
parent b4b08aa3fd
commit e98798894e
7 changed files with 33 additions and 21 deletions
@@ -123,7 +123,7 @@ namespace Musify.Application.Tracks
return Error.Failure(description: $"Failed to create track for {request.Title}");
}
return TrackApplicationResponse.FromEntity(trackEntity);
return TrackApplicationResponse.FromEntity(trackEntity, listensCount: 0);
}
}
}