refactor(backend): group track pipeline state into owned types

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.
This commit is contained in:
2026-07-17 17:58:56 +02:00
parent 6e2f3a257a
commit aae45a5186
19 changed files with 270 additions and 124 deletions
+4 -43
View File
@@ -1,6 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using Musify.Domain.Abstractions;
using Musify.Domain.ValueObjects;
@@ -31,47 +30,19 @@ namespace Musify.Domain.Entities
[MaxLength(16)]
public string? ExternalId { get; set; }
[Required]
public bool DownloadRequested { get; set; } = false;
[MaxLength(64)]
public string? OriginalPictureName { get; set; }
[MaxLength(64)]
public string? SmallPictureName { get; set; }
[MaxLength(64)]
public string? MediumPictureName { get; set; }
[MaxLength(64)]
public string? LargePictureName { get; set; }
[MaxLength(64)]
public string? OriginalAudioName { get; set; }
[MaxLength(64)]
public string? AudioFolderName { get; set; }
[Required]
public ProcessingStatus PicturesProcessingStatus { get; set; } = ProcessingStatus.Pending;
[Required]
public ProcessingStatus AudioTranscodeProcessingStatus { get; set; } = ProcessingStatus.Pending;
[Required]
public LifeCycleStatus LifeCycleStatus { get; set; } = LifeCycleStatus.Active;
[Required]
public int RetryCount { get; set; } = 0;
public DateTime? LastRetryAt { get; set; }
[Required]
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
[Required]
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
public TrackPictures Pictures { get; set; } = new();
public TrackAudio Audio { get; set; } = new();
[ForeignKey(nameof(OwnerUserId))]
public User? Owner { get; set; }
@@ -82,15 +53,5 @@ namespace Musify.Domain.Entities
public ICollection<ListeningHistory> ListeningHistories { get; set; } = new List<ListeningHistory>();
public ICollection<TrackArtist> TrackArtists { get; set; } = new List<TrackArtist>();
[NotMapped]
[MemberNotNullWhen(true, nameof(SmallPictureName)) ]
[MemberNotNullWhen(true, nameof(MediumPictureName)) ]
[MemberNotNullWhen(true, nameof(LargePictureName)) ]
public bool IsPicturesProcessed => PicturesProcessingStatus == ProcessingStatus.Completed;
[NotMapped]
[MemberNotNullWhen(true, nameof(AudioFolderName)) ]
public bool IsAudioProcessed => AudioTranscodeProcessingStatus == ProcessingStatus.Completed;
}
}