namespace DeepDrftModels.Entities;

/// <summary>
/// Incremental rollup of play counts per track (Phase 16 §4.1 / D6). One row per track, bumped inside
/// the same transaction that appends the <see cref="PlayEvent"/> — no background aggregation job. The
/// home card and per-target reads sum these instead of <c>COUNT(*)</c>-ing the event log on every
/// landing. Release totals are <em>derived</em> (D4) by summing the counters of the release's tracks,
/// so there is no separate release-counter row — this keeps the rollup normalized at one row per track.
/// </summary>
public class PlayCounter
{
    public long Id { get; set; }

    /// <summary>The track these counts belong to (SQL id). Unique — one counter row per track.</summary>
    public long TrackId { get; set; }

    /// <summary>Count of plays that ended in the <c>Partial</c> bucket (&lt; 30%).</summary>
    public long PartialCount { get; set; }

    /// <summary>Count of plays that ended in the <c>Sampled</c> bucket (30%–80%).</summary>
    public long SampledCount { get; set; }

    /// <summary>Count of plays that ended in the <c>Complete</c> bucket (&gt; 80%).</summary>
    public long CompleteCount { get; set; }

    /// <summary>Total plays for the track — the sum of the three bucket counts (headline figure).</summary>
    public long TotalPlays => PartialCount + SampledCount + CompleteCount;
}
