This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

perf: use json_extract for landing page, avoid loading 100KB+ records

Landing page only needs id, lexmin, title — extract those via
json_extract instead of pulling the full record (117KB each).

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>

author
nandi
co-author
Letta Code
date (May 14, 2026, 3:35 AM UTC) commit b0be4482 parent 587b78f3
+7 -16
+7 -16
src/worker.ts
··· 379 379 380 380 // Landing page — strata records feed 381 381 app.get("/", async (c) => { 382 - // Just load summaries for the landing page — client-side will fetch full data 382 + // Load only the fields we need — records are 100KB+ with embedded connections 383 383 let islandsJson = "[]"; 384 384 try { 385 385 await ensureContrailReady(db); 386 386 const rows = await db 387 - .prepare("SELECT uri, record FROM records_strata ORDER BY time_us DESC LIMIT 10") 388 - .all<{ uri: string; record: string }>(); 387 + .prepare("SELECT uri, json_extract(record, '$.source.uri') as lexmin, json_extract(record, '$.analysis.title') as title FROM records_strata ORDER BY time_us DESC LIMIT 10") 388 + .all<{ uri: string; lexmin: string | null; title: string | null }>(); 389 389 390 390 const islands: any[] = []; 391 391 for (const row of rows.results || []) { 392 - try { 393 - const rec = JSON.parse(row.record); 394 - const lexmin = rec.source?.uri; 395 - if (!lexmin) continue; 396 - const lexminHash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(lexmin)); 397 - const id = Array.from(new Uint8Array(lexminHash)).map(b => b.toString(16).padStart(2, "0")).join("").slice(0, 16); 398 - islands.push({ 399 - id, 400 - lexmin, 401 - title: rec.analysis?.title || null, 402 - recordUri: row.uri, 403 - }); 404 - } catch {} 392 + if (!row.lexmin) continue; 393 + const lexminHash = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(row.lexmin)); 394 + const id = Array.from(new Uint8Array(lexminHash)).map(b => b.toString(16).padStart(2, "0")).join("").slice(0, 16); 395 + islands.push({ id, lexmin: row.lexmin, title: row.title || null, recordUri: row.uri }); 405 396 } 406 397 islandsJson = JSON.stringify(islands); 407 398 } catch (e) {