gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf83571c3f83571c3tracker#18 (mission 067): daily sync by change lists — TMDB /tv|movie/changes (since the stored day, paged) + TVmaze /updates/shows → only our changed titles (followed: full step, unfollowed: light step — changed seasons, no TVmaze), full walk on first run / gap > 14 days / failed list; show record refreshed (title, tmdbSummary, tagline, status, genres …; renamed titles re-indexed); summary = the creator's own text (page: summary > tmdbSummary > tvmazeSummary), one-time clear of copied summaries (9,647 on the live copy); gate 261, tests/realdata-018*.mjs, README + STATUSmref83571c3/tests/realdata-search.mjs

6.6 KB

  1. // tests/realdata-search.mjs — tracker.worldapi.org#14 REAL-DATA check of the search (NOT part of the gate): a dev server
  2. // (TRACKER_REAL_BASE, default http://127.0.0.1:8770) over a COPY of Byrodin's storage/ with the REAL TMDB (the dev .env),
  3. // a session file for the creator (az5b2) whose id is in .scratch/real-sid (STATUS.md "ticket #14" has the procedure).
  4. // Times: the page load, every keystroke → its results, "Fetch from web", an import (it WRITES — a copy only!) and the
  5. // imported show's page; screenshots 390 + 1280 into TRACKER_REAL_SHOTS (default /tmp/w052-t14/real). Run: node tests/realdata-search.mjs
  6. import { writeFileSync, readFileSync, mkdirSync } from 'node:fs';
  7. import { launchBrowser } from './cdp.mjs';
  8. process.env.HL_CHROME ||= '/opt/google/chrome/chrome';
  9. const BASE = process.env.TRACKER_REAL_BASE || 'http://127.0.0.1:8770';
  10. const OUT = process.env.TRACKER_REAL_SHOTS || '/tmp/w052-t14/real';
  11. const SID = readFileSync('.scratch/real-sid', 'utf8').trim();
  12. const [CH_FROM, CH_TO] = (process.env.TRACKER_REAL_CHROME || '8771-8772').split('-').map(Number);
  13. // a title the real data has, and one it does not (the import); override with env
  14. const HAVE = process.env.TRACKER_REAL_HAVE || 'doctor who';
  15. const WEB = process.env.TRACKER_REAL_WEB || 'severance';
  16. mkdirSync(OUT, { recursive: true });
  17. const browser = await launchBrowser({ debugPortRange: [CH_FROM, CH_TO] });
  18. const page = await browser.newPage();
  19. const ev = (e) => page.evaluate(e);
  20. await page.send('Network.enable', {});
  21. await page.send('Network.setCookie', { name: 'trackersid', value: SID, url: BASE });
  22. const hydrated = () => page.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1 && document.readyState === "complete"', { timeout: 30000, label: 'hydrated' });
  23. const shot = async (n) => writeFileSync(`${OUT}/${n}.png`, Buffer.from((await page.send('Page.captureScreenshot', { format: 'png' })).data, 'base64'));
  24. const titles = () => ev(`JSON.stringify(Array.from(document.querySelectorAll('#titles .search-title')).map(a => a.textContent))`);
  25. const res = [];
  26. for (const [w, h, mobile] of [[390, 844, true], [1280, 900, false]]) {
  27. await page.send('Emulation.setDeviceMetricsOverride', { width: w, height: h, deviceScaleFactor: mobile ? 2 : 1, mobile });
  28. let t = Date.now();
  29. await page.goto(BASE + '/search');
  30. await hydrated();
  31. res.push(`${w} /search load ${Date.now() - t} ms, signed in: ${await ev(`!!document.querySelector('#logout')`)}, focused: ${await ev(`document.activeElement && document.activeElement.id`)}`);
  32. // type HAVE letter by letter, timing each keystroke until the address and the list follow it
  33. let typed = '';
  34. const per = [];
  35. for (const ch of HAVE) {
  36. typed += ch;
  37. t = Date.now();
  38. await page.type('#searchinput', ch);
  39. await page.waitFor(`location.pathname === ${JSON.stringify(typed.trim() ? '/search/' + encodeURIComponent(typed.trim()) : '/search')} && document.querySelector('search-page').getAttribute('data-for') === ${JSON.stringify(typed)}`, { timeout: 10000 });
  40. per.push(Date.now() - t);
  41. }
  42. res.push(`${w} typing "${HAVE}": per keystroke ms ${per.join(',')}; first titles ${(JSON.parse(await titles())).slice(0, 4).join(' | ')}; ${await ev(`document.querySelectorAll('search-row').length`)} rows; scrollW ${await ev('document.documentElement.scrollWidth')}`);
  43. await shot(`search-typed-${w}`);
  44. // a reload of the address opens the same results (server render)
  45. t = Date.now();
  46. await page.goto(BASE + '/search/' + encodeURIComponent(HAVE));
  47. await hydrated();
  48. res.push(`${w} reload /search/${encodeURIComponent(HAVE)} ${Date.now() - t} ms, input "${await ev(`document.querySelector('#searchinput').value`)}", ${(JSON.parse(await titles())).length} titles`);
  49. }
  50. // the web + the import, once (1280)
  51. await page.goto(BASE + '/search/' + encodeURIComponent(WEB));
  52. await hydrated();
  53. res.push(`db for "${WEB}": ${await titles()}`);
  54. let t = Date.now();
  55. await page.click('#fetchweb');
  56. await page.waitFor(`document.querySelectorAll('web-row').length > 0 || !!document.querySelector('#webnote')`, { timeout: 30000, label: 'web results' });
  57. res.push(`fetch from web "${WEB}" ${Date.now() - t} ms: ${await ev(`JSON.stringify(Array.from(document.querySelectorAll('web-row')).map(r => r.querySelector('web-title').textContent + ' [' + r.querySelector('button.add').value + ']'))`)} ${await ev(`document.querySelector('#webnote') ? document.querySelector('#webnote').textContent : ''`)}`);
  58. await page.waitFor(`Array.from(document.querySelectorAll('web-row img')).every(i => i.complete)`, { timeout: 15000 }).catch(() => {});
  59. await shot('search-web-1280');
  60. await page.send('Emulation.setDeviceMetricsOverride', { width: 390, height: 844, deviceScaleFactor: 2, mobile: true });
  61. await shot('search-web-390');
  62. await page.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false });
  63. if (process.env.TRACKER_REAL_IMPORT !== '0' && await ev(`document.querySelectorAll('web-row').length`) > 0) {
  64. const key = await ev(`document.querySelector('web-row button.add').value`);
  65. t = Date.now();
  66. await page.click(`web-row button.add[value="${key}"]`);
  67. await page.waitFor(`location.pathname.startsWith('/shows/') && !!document.querySelector('show-header h1')`, { timeout: 60000, label: 'imported show page' });
  68. res.push(`import ${key} → ${await ev('location.pathname')} in ${Date.now() - t} ms: ${await ev(`JSON.stringify({ h1: document.querySelector('show-header h1').textContent, seasons: Array.from(document.querySelectorAll('season-row')).map(r => r.querySelector('season-label').textContent + ': ' + r.querySelector('season-count').textContent).slice(0, 6), poster: document.querySelector('show-poster img') ? document.querySelector('show-poster img').getAttribute('src') : null, links: Array.from(document.querySelectorAll('a.extlink')).map(a => a.textContent) })`)}`);
  69. await page.waitFor(`!document.querySelector('show-poster img') || document.querySelector('show-poster img').complete`, { timeout: 15000 }).catch(() => {});
  70. await shot('imported-show-1280');
  71. // searched again: now in our database, and no longer in the web list
  72. await page.goto(BASE + '/search/' + encodeURIComponent(WEB));
  73. await hydrated();
  74. res.push(`after import, db for "${WEB}": ${await titles()}`);
  75. await page.click('#fetchweb');
  76. await page.waitFor(`document.querySelectorAll('web-row').length > 0 || !!document.querySelector('#webnote')`, { timeout: 30000 });
  77. res.push(`after import, web keys: ${await ev(`JSON.stringify(Array.from(document.querySelectorAll('web-row button.add')).map(b => b.value))`)} (${key} must be gone)`);
  78. }
  79. console.log(res.join('\n'));
  80. console.log('problems', JSON.stringify(page.problems()));
  81. await browser.close();

Branches

Latest commits

  • f83571c3tracker#18 (mission 067): daily sync by change lists — TMDB /tv|movie/changes (since the stored day, paged) + TVmaze /updates/shows → only our changed titles (followed: full step, unfollowed: light step — changed seasons, no TVmaze), full walk on first run / gap > 14 days / failed list; show record refreshed (title, tmdbSummary, tagline, status, genres …; renamed titles re-indexed); summary = the creator's own text (page: summary > tmdbSummary > tvmazeSummary), one-time clear of copied summaries (9,647 on the live copy); gate 261, tests/realdata-018*.mjs, README + STATUSmre
  • 10bb3f93tracker#28 (mission 061): full cast (all seasons, main cast by episodes, guest stars) + crew (created by, directed by, written by, screenplay, story, music) — stored by the details completion, the daily sync, the search import (one details request) and a background credits job (resumes, RSS limit); show page collapsed after 20 with client-side Show all; showBySlug via a slug map; gate 249, tests/realdata-028.mjs, README + STATUSmre
  • 25a50bc4tracker#26 (mission 059): titles from a filmography are completed — on open (skeleton, step-wise face showComplete, no reload) and by the in-app details repair (resumes, TMDB-paced, series in parts); cast from TMDB credits; gate 231, tests/realdata-026.mjs, README + STATUSmre
  • 1704ec45tracker#17 (mission 057): season caret down/up, skeleton rows while a season loads, sessionless showSeasonEpisodes face (no page re-mount), client-only close; gate 214, tests/realdata-057.mjs, README + STATUSmre
  • f2fe3e36mission 056: README + STATUS (merge, fixes, Hybriel 8590df63, real-data check), tests/realdata-056.mjs, tools/check-public-slugs.hlmre
  • f40c250emission 056: re-vendor hybriel master 8590df63 (#121, #122); an adult title's page is Not found for non-followers; gate: leave the page before stopping the servermre
  • 2b7fdd6cmission 056: signed-out header one row on phones ("Log in", nowrap), backfill skips adult titles' posters, gate checksmre
  • 2c53d5efMerge branch 't16-person' (tracker#16 person pages) into main; filmography shows only public titles (054 adult flag), gate race fix (backfill start line)mre
  • c171227emission 054: hide adult/unknown titles from the public lists and the search; in-app adult-flag backfill (TMDB details + poster per title, resumes), gate + real-data proofmre
  • 139fafd8tracker#16: short bio (4 lines, click = all), real-data check script, README + STATUSmre
  • 93be9476tracker#16: person pages /person/<slug> with the filmography fetched from TMDB on the first visit (step by step), gatemre
  • 47a3cae6STATUS: mission 053 merge commit idsmre
  • dcc5eecaMerge branch 't14-search'mre
  • 03edc783Merge branch 't15-tvmaze'mre
  • 71b46345tracker#15: numbering check by date or title, placeholder titles in other languages, docs + real-data proofmre
  • 6bb2daf1tracker#13: homepage (tiles, intro, latest movies/shows), /shows, /movies/page/N, /my/movies; lists cached in memorymre
  • b8bd1157tracker#14: README + STATUS (search, real-data numbers, gate, merge notes)mre
  • 65c694a8tracker#14: search — header magnifier, /search/<text> (in-memory word-prefix index over titles + people), Fetch from web (TMDB search/multi, ours left out), Add = import via syncShow; gate +25 checks, real-data scriptmre
  • 34f2c15btracker#15: TVmaze merge in the sync (gaps only: new episodes/seasons, empty titles/air dates; numbering check), fake TVmaze episodes + gatemre
  • cbdc4ea7tracker#12: link icons TMDB/IMDb/TVDB/TVmaze; sync fills missing ids (TVmaze lookup); movies fetched via /movie/mre