Capstone — Library Dashboard
Definition
The library dashboard combines an index, a cleaned play log, counts, leaders and a two-pointer window in one function, so every figure comes from a few single passes over the data and the total cost stays O(t + p).
In plain words
It is a control panel fed by several small tools, each doing one job in one pass: build the index, tidy the log, count, pick the leaders, find the session. The skill is choosing the right structure for each job so nothing is searched twice.
In short: every lesson in this section built one piece of Tunebox's
library — the scale planner, the playlist, the session finder, the song
index. The home screen's library dashboard runs them together: library
size, plays, top track and artist, and the longest session that fits your
free time, all from one function, library_dashboard(), on every refresh.
A real library is messy and a real play log is long, so it must stay
O(t + p) for t tracks and p plays — a pass or two over each, never a
loop inside a loop, never in on a list, never pop(0).

What you're building
library_dashboard(tracks, plays, budget)tracks— the library, a list of dicts like{"id": "t1", "title": "Glow", "artist": "Nova", "mins": 4}. A messy import can list the same id twice; the first copy is the real track.plays— the play log: track ids in the order they were played. Ids that aren't in the library (deleted tracks) are ignored.budget— a number of minutes.