Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit ba963c52531d3b9fcd242f5331bbde13c24f394d
parent d2235841bcda1a05aa73755bda39c1b51ba38c51
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri, 25 Sep 2026 14:09:56 -0400

channels: matchesVideoQuery above parseFilters' comment, and a unit test for it (review L1, L2)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Aeditor/app/channels/[slug]/lib/videoRows.test.ts | 47+++++++++++++++++++++++++++++++++++++++++++++++
Meditor/app/channels/[slug]/lib/videoRows.ts | 6+++---
2 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/editor/app/channels/[slug]/lib/videoRows.test.ts b/editor/app/channels/[slug]/lib/videoRows.test.ts @@ -0,0 +1,47 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { matchesVideoQuery, type VideoRow } from "./videoRows"; + +// The one predicate behind BOTH the list's search box (VideoListPane) and the +// server's `?q=` ordering for the detail pane's prev/next (videos/page.tsx). + +function row(id: string, title?: string): VideoRow { + return { + id, + ...(title ? { title } : {}), + downloaded: false, + transcribed: false, + untranscribable: false, + partial: false, + corruptSource: false, + corruptFullSource: false, + failedTranscription: false, + wrongFormatAudio: false, + excluded: false, + incompleteTranscript: false, + digestWarnings: false, + shortAudio: false, + running: false, + status: "not_downloaded", + }; +} + +test("matches the id, case-insensitively", () => { + assert.equal(matchesVideoQuery(row("AbC123xyz"), "abc123"), true); + assert.equal(matchesVideoQuery(row("AbC123xyz"), " XYZ "), true); + assert.equal(matchesVideoQuery(row("AbC123xyz"), "nope"), false); +}); + +test("matches the title, case-insensitively", () => { + const r = row("vid00000001", "Moonlit Harbor Interview"); + assert.equal(matchesVideoQuery(r, "harbor"), true); + assert.equal(matchesVideoQuery(r, "HARBOR interview"), true); + assert.equal(matchesVideoQuery(r, "vid0000"), true); + assert.equal(matchesVideoQuery(r, "sunrise"), false); +}); + +test("a row with no title matches on the id only; a blank query matches all", () => { + assert.equal(matchesVideoQuery(row("vid1"), "harbor"), false); + assert.equal(matchesVideoQuery(row("vid1"), ""), true); + assert.equal(matchesVideoQuery(row("vid1", "Anything"), " "), true); +}); diff --git a/editor/app/channels/[slug]/lib/videoRows.ts b/editor/app/channels/[slug]/lib/videoRows.ts @@ -146,9 +146,6 @@ export function filterRows( ); } -// Parse the comma-separated `?filter=` value into a set of valid filters, -// ignoring unknown/legacy tokens (including "all"). A single legacy -// `?filter=transcribed` parses to a one-element set, so old links still work. // The search box: a case-insensitive substring of the id OR the title. export function matchesVideoQuery(r: VideoRow, q: string): boolean { const needle = q.trim().toLowerCase(); @@ -159,6 +156,9 @@ export function matchesVideoQuery(r: VideoRow, q: string): boolean { ); } +// Parse the comma-separated `?filter=` value into a set of valid filters, +// ignoring unknown/legacy tokens (including "all"). A single legacy +// `?filter=transcribed` parses to a one-element set, so old links still work. export function parseFilters(raw: string | undefined): Set<VideoFilter> { const out = new Set<VideoFilter>(); if (!raw) return out;