From dbd5c50e8d0bd72032f54747d7cb39b68b2f9770 Mon Sep 17 00:00:00 2001 From: Ada Date: Thu, 16 Apr 2026 09:11:40 -0400 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20feat:=20Add=20=3Ftype?= =?UTF-8?q?=3D=20query=20filter=20to=20GET=20/lab-notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enable filtering published notes by type via query parameter, e.g. GET /lab-notes?type=tail. Validates against ALLOWED_NOTE_TYPES and silently returns all types if the value is invalid. Follows the existing locale filter pattern — adds a conditional WHERE clause without breaking the default (unfiltered) behavior. Co-authored-by: Sage --- src/routes/labNotesRoutes.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/routes/labNotesRoutes.ts b/src/routes/labNotesRoutes.ts index 9c6180a..55cf40e 100644 --- a/src/routes/labNotesRoutes.ts +++ b/src/routes/labNotesRoutes.ts @@ -4,6 +4,7 @@ import type Database from "better-sqlite3"; import type { LabNoteRecord, TagResult } from "../types/labNotes.js"; import { mapToLabNotePreview, mapToLabNoteView } from "../mappers/labNotesMapper.js"; import { normalizeLocale, inferLocale } from "../lib/helpers.js"; +import { ALLOWED_NOTE_TYPES } from "../types/labNotes.js"; import { expandMascotBlocks } from "../lib/markdownBlocks.js"; import { marked } from "marked"; @@ -20,6 +21,11 @@ export function registerLabNotesRoutes(app: any, db: Database.Database) { try { const locale = normalizeLocale(req.query.locale); + const rawType = String(req.query.type ?? "").toLowerCase(); + const typeFilter = ALLOWED_NOTE_TYPES.has(rawType as any) ? rawType : null; + + const typeClause = typeFilter ? "AND type = ?" : ""; + const orderBy = ` ORDER BY published_at DESC, @@ -34,6 +40,7 @@ export function registerLabNotesRoutes(app: any, db: Database.Database) { published_at, created_at, updated_at, card_style FROM v_lab_notes WHERE status = 'published' + ${typeClause} ${orderBy} `; @@ -46,12 +53,20 @@ export function registerLabNotesRoutes(app: any, db: Database.Database) { FROM v_lab_notes WHERE locale = ? AND status = 'published' + ${typeClause} ${orderBy} `; - const notes = (locale === "all" - ? db.prepare(sqlAll).all() - : db.prepare(sqlByLocale).all(locale)) as LabNoteRecord[]; + const notes = (() => { + if (locale === "all") { + return typeFilter + ? db.prepare(sqlAll).all(typeFilter) + : db.prepare(sqlAll).all(); + } + return typeFilter + ? db.prepare(sqlByLocale).all(locale, typeFilter) + : db.prepare(sqlByLocale).all(locale); + })() as LabNoteRecord[]; const mapped = notes.map((note) => { const tagRows = db From 4a60d613eede3ac656354654e99480e7e7dfec0d Mon Sep 17 00:00:00 2001 From: Ada Date: Thu, 16 Apr 2026 09:12:01 -0400 Subject: [PATCH 2/2] Auto stash before checking out "origin/main" --- .claude/settings.local.json | 9 --------- .gitignore | 2 ++ 2 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 .claude/settings.local.json diff --git a/.claude/settings.local.json b/.claude/settings.local.json deleted file mode 100644 index eb47eda..0000000 --- a/.claude/settings.local.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "permissions": { - "allow": [ - "Bash(npm rebuild:*)", - "Bash(npx tsc:*)", - "Bash(npm test:*)" - ] - } -} diff --git a/.gitignore b/.gitignore index 1c01ac9..9e52b9b 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,5 @@ ecosystem.config.cjs coverage/ /data/lab.dev-backup-20260127.db + +.claude/settings.local.json