package com.fabledsword.minstrel.cache.db.entities

import androidx.room.Entity
import androidx.room.PrimaryKey
import kotlinx.datetime.Clock
import kotlinx.datetime.Instant

/**
 * The current user's quarantine flag for one track. Mirrors
 * `flutter_client/lib/cache/db.dart`'s `CachedQuarantineMine` Drift
 * table.
 *
 * The flat denormalized track/album/artist columns let the Quarantine
 * screen render off this single table without a join — the server
 * returns the full snapshot on /api/me/quarantine so we mirror that
 * shape locally.
 *
 * `createdAt` is the server-issued timestamp preserved as an opaque
 * ISO-8601 string (it's the canonical "when this was flagged" value);
 * `fetchedAt` is our local sync-time marker.
 */
@Entity(tableName = "cached_quarantine_mine")
data class CachedQuarantineEntity(
    @PrimaryKey val trackId: String,
    val reason: String,
    val notes: String? = null,
    val createdAt: String,
    val trackTitle: String,
    val trackDurationMs: Int = 0,
    val albumId: String,
    val albumTitle: String,
    val albumCoverArtPath: String? = null,
    val artistId: String,
    val artistName: String,
    val fetchedAt: Instant = Clock.System.now(),
)
