Track mixed catalog fields (Title, Artist credit, Duration) with picture-processing and audio-transcode pipeline state as ten flat columns plus two computed [NotMapped] flags, making the entity read like a media-pipeline worksheet. Introduce TrackPictures and TrackAudio as EF owned types mapped onto the same existing columns (explicit column names, no schema change - verified via `dotnet ef migrations has-pending-model-changes`). Track now reads as Title/Artist/Duration/Pictures/Audio instead of fourteen loose properties.
45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using System.Linq;
|
|
using Musify.Domain.Entities;
|
|
using Musify.Domain.ValueObjects;
|
|
|
|
namespace Musify.Application.Tracks.Responses
|
|
{
|
|
public record TrackApplicationResponse(
|
|
Guid Id,
|
|
string Title,
|
|
string? Artist,
|
|
TrackSource Source,
|
|
string? ExternalId,
|
|
ProcessingStatus AudioStatus,
|
|
int Duration,
|
|
int ListensCount,
|
|
long? OwnerUserId,
|
|
DateTime CreatedAt,
|
|
DateTime UpdatedAt)
|
|
{
|
|
public static TrackApplicationResponse FromEntity(Track track, int listensCount) =>
|
|
new(
|
|
track.Id,
|
|
track.Title,
|
|
FormatArtist(track),
|
|
track.Source,
|
|
track.ExternalId,
|
|
track.Audio.TranscodeStatus,
|
|
track.Duration,
|
|
listensCount,
|
|
track.OwnerUserId,
|
|
track.CreatedAt,
|
|
track.UpdatedAt);
|
|
|
|
private static string? FormatArtist(Track track)
|
|
{
|
|
if (track.TrackArtists.Count == 0)
|
|
return null;
|
|
|
|
return string.Join(", ", track.TrackArtists
|
|
.OrderBy(trackArtist => trackArtist.Position)
|
|
.Select(trackArtist => trackArtist.Artist.Name));
|
|
}
|
|
}
|
|
}
|