mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 15:11:58 +01:00
Song playCount/played are parsed and synced, then aggregated per album (SUM/MAX) and per artist (through the album's artistId) after the song sync. Albums and artists gain Frequent/Recent sorts with their own indices; the options show only when the active source returned the fields, and the aggregate only writes rows whose value changed. The artist subqueries pin index_albums_sourceId_artistId: without it the planner answers MAX(played) from index_albums_recent (sourceId, played), which cannot apply the artistId equality, and scans every album once per artist. The availability flows read the indexed album ranks rather than scanning songs, which would re-run on every song-sync batch.