feat(backend): expose track duration and listen count in track response
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user