tracker
All repositories: gitoria
5.5 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`. Since #13 SERIES only — the movies a user follows are /my/movies// (components/mymovies.hl). Reused (not copied): `followsOfUser`, `insertByFollowDesc` (follows.hl),// `watchesOfUser` (watches.hl), `cardOf`/`episodeKeyOf`/`posterUrlOfName`/`episodeCode` (shows.hl).//// COST (tracker#30, mission 025): no record is read per load — each followed title's slim cached card (shows.hl cardOf) and// each watched episode's cached { show s e } (episodeKeyOf; the user's watches are kept, watches.hl). Before, one fetch per// followed title (cast + crew) and one per watched episode (11.7k) — 4.4 s on a process after the first-start jobs.//// tracker.worldapi.org#21 (mission 068): TWO lists from this one component — `/my/series` (the followed SERIES) and `/my/shows`// (the followed SHOWS: reality, talk, news; shows.hl titleKind) — routed as `/my/:tv` (project.hl, after the other /my/ routes);// any other word is "Not found". Each row links to the title's own page (shows.hl titlePath).parent './main.hl'import { appTitle } from '../project.hl'import { userIdOfSession } from '../lib/users.hl'import { followsOfUser, insertByFollowDesc } from '../lib/follows.hl'import { cardOf, episodeKeyOf, posterUrlOfName, episodeCode } from '../lib/shows.hl'import { watchesOfUser } from '../lib/watches.hl'// ---- pure helpers (static: an mpackdb-backed helper must be `static`, hybriel#115/#116) ------// show id → the highest watched episode of it { seasonNumber, episodeNumber }, only for the shows in `follows` — by each// watched episode's own `show` (shows.hl episodeKeyOf, cached), so an episode outside the title's seasons still countsstatic lastWatchedOf = (&userId, &follows) => {followed = {}for (f of follows) { followed[f.show] = true }best = {}for (w of watchesOfUser(&userId)) {if (w.targetType == 'episode' && w.target != null) {let k = episodeKeyOf(&w.target)if (k.show != null && followed[k.show] == true && k.s != null && k.e != null) {let b = best[k.show]if (b == null || k.s > b.seasonNumber || (k.s == b.seasonNumber && k.e > b.episodeNumber)) {best[k.show] = { seasonNumber = k.s episodeNumber = k.e }}}}}return best}// the kind a list shows: 'series' for /my/series, 'show' for /my/shows, null for anything elsestatic listKindOf = (&tv) => { return tv == 'series' ? 'series' : (tv == 'shows' ? 'show' : null) }static myShowsRowsOf = (&userId, &kind) => {if (userId == null || kind == null) { return [] }// tracker.worldapi.org#13: movies have their own list, /my/movies; #21: series and shows each theirsfollows = []for (f of followsOfUser(&userId)) {let c = cardOf(&f.show)if (c != null && c.type != 'movie' && c.kind == kind) { follows.push(f) }}last = lastWatchedOf(&userId, &follows)let out = []for (f of follows) {let c = cardOf(&f.show)if (c != null) {let lw = last[c.id]let hasEpisode = lw != nullout = insertByFollowDesc(&out, {id = c.id title = c.titleYear href = c.hrefposterUrl = posterUrlOfName(&c.posterName)hasEpisode = hasEpisodeepisodeLabel = hasEpisode ? episodeCode(&lw.seasonNumber, &lw.episodeNumber) : ''followedAt = f.at != null ? f.at : 0})}}return out}// ---- reactive members -----------------------------------------------------------------------tv = nulllistKind = listKindOf(&tv)found = listKind != nullnotFound = listKind == nullisSeries = listKind == 'series'listWord = isSeries ? 'Series' : 'Shows'listClass = isSeries ? 'type-word type-series' : 'type-word type-show'session = nulluserId = userIdOfSession(&session)signedIn = userId != null// a plain copy of userId for `rows` (mission 047: session sync, see components/show.hl `me`)me = userIdrows = signedIn ? myShowsRowsOf(&me, &listKind) : []hasRows = rows.length > 0noRows = found && !hasRowsemptyText = signedIn ? (isSeries ? 'You follow no series yet.' : 'You follow no shows yet.') : (isSeries ? 'Sign in to see the series you follow.' : 'Sign in to see the shows you follow.')__title = found ? 'My ' + listWord.toLowerCase() + ' — ' + appTitle : appTitleView {myShowsPage { "data-kind" = listKindif (notFound) {h1 { "Not found" }p { "This list doesn't exist." }}// tracker.worldapi.org#20: "My" and the list's type word in its colourif (found) { h1 { class = "typed" "My" typeWord { class = listClass listWord } } }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
Latest commits
- 8dfe42c8mission DP62mre
- e347fef4Merge rv44: tracker#61 #62 on Hybriel day44mre
- 8274bcf1log: RV44 done, deploy held for the usage windowmre
- 1ef7a3b1RV44: report day44 gates and migration/restart proofsmre
- a5f62f6cRV44: re-vendor Hybriel set day44 (source 222edef7, bin 4f0f263e)mre
- 6159a248Merge branch 'hm62-personindex' into rv44mre
- a8923d93log: RV44 startedmre
- cf28cf77mission RV44mre
- 585782dfLog: tracker#60 Chrome look, STATUS rewrittenmre
- 147d0172conductor: caramboleyo is the user, not owner/creatorApollo
- 21dd0cfblog: #60 live measurement, reviewmre
- 7793cf94HM62b report: person indexes with fixed mpackdbmre
- b4c8d3a9Document tracker#62 fixed-index migration and GC proofmre
- 09d66ed5status: #60 livemre
- 4171672flog: #60 livemre
- f52862a2log: HM62b startedmre
- 88fde2c4mission HM62bmre
- a722e526log: #62 blocked by hybriel#317mre
- 074a7418log: #62 assigned to Tracker; pending rulemre
- 06f6ae8fHM62 report: mpackdb index gapmre