tracker
All repositories: gitoria
4.3 KB
// components/myshows.hl — `/my/shows` (tracker.worldapi.org#7): every show the signed-in user follows,// the one followed last on top. Creator's words: "trackers /my/shows that just ists the shows in desc// order i followed them, small poster, title, last episode like s08e35". Each row: the small poster (the// same `/posters/<name>` route + placeholder as the show page, shows.hl `posterUrlOf`: one `/posters/none` URL when the file is missing), the title linking// to `/shows/<slug>`, and the LAST WATCHED episode as `S08E35` — the architect's reading (in the ticket):// the highest season/episode number the user has watched of that show; nothing watched → no episode.//// Read-only page (no check icons, no click), so like /schedule it needs no `on server` face — `rows` is// one server-side render from `session`. Reused (not copied): `followsOfUser` (follows.hl),// `watchesOfUser` (watches.hl), `showById`/`episodeById`/`posterUrlOf`/`episodeCode`/`titleWithYear` (shows.hl).//// COST: only the user's own follows and watches are touched — one fetch per followed show and one fetch// per watched EPISODE (never a scan of all episodes/seasons of a followed show, unlike /unwatched): the// followed shows go into a map first, then each episode watch's episode is fetched once and kept only// if it is higher than that show's current best (measured on a copy of the real data, STATUS.md).parent './main.hl'import { appTitle } from '../project.hl'import { userIdOfSession } from '../users.hl'import { followsOfUser } from '../follows.hl'import { showById, episodeById, posterUrlOf, episodeCode, titleWithYear } from '../shows.hl'import { watchesOfUser } from '../watches.hl'// ---- pure helpers (static: an mpackdb-backed helper must be `static`, hybriel#115/#116) ------// insertion sort, hand-written (no list sort(), hybriel#1) — newest follow first; `at` is epoch ms// (migrated `_createdAt`, or now() for a new follow), a missing one counts as the oldeststatic insertByFollowDesc = (sorted, row) => {let out = []let inserted = falsefor (x of sorted) {if (!inserted && row.followedAt >= x.followedAt) { out.push(row) inserted = true }out.push(x)}if (!inserted) { out.push(row) }return out}// show id → the highest watched episode of it { seasonNumber, episodeNumber }, only for shows in `followed`static lastWatchedOf = (userId, followed) => {let best = {}for (w of watchesOfUser(userId)) {if (w.targetType == 'episode' && w.target != null) {let e = episodeById(w.target)if (e != null && e.show != null && followed[e.show] == true && e.seasonNumber != null && e.episodeNumber != null) {let b = best[e.show]if (b == null || e.seasonNumber > b.seasonNumber || (e.seasonNumber == b.seasonNumber && e.episodeNumber > b.episodeNumber)) {best[e.show] = { seasonNumber = e.seasonNumber episodeNumber = e.episodeNumber }}}}}return best}static myShowsRowsOf = (userId) => {if (userId == null) { return [] }let follows = followsOfUser(userId)let followed = {}for (f of follows) { followed[f.show] = true }let last = lastWatchedOf(userId, followed)let out = []for (f of follows) {let show = showById(f.show)if (show != null) {let lw = last[show.id]let hasEpisode = lw != nullout = insertByFollowDesc(out, {id = show.id title = titleWithYear(show) href = '/shows/' + show.urlSegmentposterUrl = posterUrlOf(show)hasEpisode = hasEpisodeepisodeLabel = hasEpisode ? episodeCode(lw.seasonNumber, lw.episodeNumber) : ''followedAt = f.at != null ? f.at : 0})}}return out}// ---- reactive members -----------------------------------------------------------------------session = nulluserId = userIdOfSession(session)signedIn = userId != nullrows = signedIn ? myShowsRowsOf(userId) : []hasRows = rows.length > 0noRows = !hasRowsemptyText = signedIn ? 'You follow no shows yet.' : 'Sign in to see the shows you follow.'__title = 'My shows — ' + appTitleView {myShowsPage {h1 { "My shows" }if (noRows) { p { class = "muted" emptyText } }if (hasRows) {myShowsRows {for (row of rows) {myShowRow {img { class = "myshow-poster" src = row.posterUrl alt = row.title }a { class = "myshow-title" href = row.href row.title }if (row.hasEpisode) { myShowEpisode { row.episodeLabel } }}}}}}}
Branches
- mainmain branch
Latest commits
- 54070a4etracker#8: /my/unwatched + /my/schedule (301 from old), S01E01, title (year), 1 episode, watched-set lookup (unwatched 15s -> 1s)mre
- 3251488atracker#7: /my/shows (followed shows, newest follow first, poster, title, last watched SxxEyy); gate can take screenshots (TRACKER_GATE_SHOTS)mre
- 44b7d9f9tracker#6: /schedule — upcoming episodes of followed shows, soonest firstmre
- 91c9fc8ctracker#5: /unwatched — unwatched released episodes of followed shows, newest firstmre
- a97c0295tracker#4: show page /shows/:slug (header, seasons, episodes, watch checks) + tools/relink-episode-seasons.hlmre
- 05f407c5tracker: no border on any button except inverted ones (Log out, ident status and identities too); header brand weight 100mre
- 17375427tracker#2: tools/migrate.hl + tools/verify.hl — old MongoDB data into mpackdb with new idsmre
- 31aac936tracker#3: no border on the header and on filled buttons; inverted buttons keep theirsmre
- 2ad9d29ctracker#1: login exactly like calendar (identity selector in the header, empty homepage)mre
- 3691e176tracker#1: empty tracker with the ident login (state of 2026-09-27)mre