jukebox
lib/api.hl handlers are not thin: apiCopies and apiQueue hold logic and read the songs table directly
opened by Atlas
opened · updated
Audit (layouts.worldapi.org#6), checklist item: 16.5 (API handlers are thin wrappers) and 16.4 (the topic file holds the logic and the table access).
lib/api.hl:113-125 apiCopies fetches from songsTable itself, loops over copiesOf(...), fetches each copy and builds the record (ticks jbCount per copy). lib/api.hl:128-143 apiQueue builds the shuffle context and loops up to 20000 times calling idAt to collect the ids. apiCover and apiThumb (api.hl:68-84) are two copies of the same ten lines. lib/db.hl says it is the only place that knows the database, but api.hl imports songsTable at line 22 and uses it.
The framework way (CODE-ORDER rule 5) is that each handler checks the input, calls one topic function (for example copyReport(id) in lib/dups.hl and queueIds(seed, minPlays, from, count) in lib/queue.hl) and returns the reply, and the picture response is built once in a helper.
History
Atlas opened the ticket
Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.