5e3441d76a
Deploy / deploy (push) Successful in 7m27s
- /contents: masonry cards, one per analysis page, with stats and a glimpse of what is inside - new node lean-theorem-proving (kind "papers"): papers matched by text, their analysis articles, benchmarks used, full paper list; node kinds: tools | papers - tools table rows get anchors Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FbMbJPadPzVwvt9rU9GBNo
65 lines
3.1 KiB
TypeScript
65 lines
3.1 KiB
TypeScript
import { query } from './db';
|
|
import { ensureAnalysisSchema } from './analysis-schema';
|
|
import type { ContentNode } from './content-tree';
|
|
|
|
export interface ListedPaper { id: number; conf: string; ext_id: string | null; title: string; conf_short: string; date: string; analysed: boolean }
|
|
export interface AnalysedArticle { slug: string; title: string; summary: string | null; paperId: number; paperTitle: string; updatedAt: string }
|
|
export interface PaperListContent {
|
|
total: number;
|
|
papers: ListedPaper[];
|
|
analysed: AnalysedArticle[];
|
|
byVenue: { conf_short: string; n: number }[];
|
|
benchmarks: { id: number; name: string; n: number }[];
|
|
}
|
|
|
|
const TEXT = `(p.title || ' ' || COALESCE(p.abstract, '') || ' ' || COALESCE(p.keywords, ''))`;
|
|
|
|
function where(node: ContentNode): { sql: string; params: string[] } {
|
|
const m = node.match;
|
|
if (!m) return { sql: 'FALSE', params: [] };
|
|
return m.require
|
|
? { sql: `${TEXT} ~ ? AND ${TEXT} ~* ?`, params: [m.pattern, m.require] }
|
|
: { sql: `${TEXT} ~ ?`, params: [m.pattern] };
|
|
}
|
|
|
|
/** Papers an analysis page of kind 'papers' is about, and the analysis articles written about them. */
|
|
export async function getPaperList(node: ContentNode): Promise<PaperListContent> {
|
|
const w = where(node);
|
|
const papers = await query<Omit<ListedPaper, 'analysed'>>(
|
|
`SELECT p.id, p.conf, p.ext_id, p.title, c.short AS conf_short, COALESCE(c.start_date, '2026-06-01') AS date
|
|
FROM papers p JOIN conferences c ON c.slug = p.conf
|
|
WHERE ${w.sql} ORDER BY date DESC, p.id`, w.params);
|
|
|
|
let articles: { slug: string; title: string; summary: string | null; subject_conf: string; subject_ext_id: string; updated_at: Date }[] = [];
|
|
try {
|
|
await ensureAnalysisSchema();
|
|
articles = await query(`SELECT slug, title, summary, subject_conf, subject_ext_id, updated_at FROM analysis.article ORDER BY updated_at DESC`);
|
|
} catch { /* no analysis schema reachable: list the papers without articles */ }
|
|
const byKey = new Map(papers.map((p) => [`${p.conf}/${p.ext_id}`, p]));
|
|
const analysed: AnalysedArticle[] = [];
|
|
const done = new Set<string>();
|
|
for (const a of articles) {
|
|
const p = byKey.get(`${a.subject_conf}/${a.subject_ext_id}`);
|
|
if (!p) continue;
|
|
done.add(`${p.conf}/${p.ext_id}`);
|
|
analysed.push({ slug: a.slug, title: a.title, summary: a.summary, paperId: p.id, paperTitle: p.title, updatedAt: new Date(a.updated_at).toISOString().slice(0, 10) });
|
|
}
|
|
|
|
const ids = papers.map((p) => p.id);
|
|
const benchmarks = ids.length
|
|
? await query<{ id: number; name: string; n: number }>(
|
|
`SELECT b.id, b.name, COUNT(DISTINCT pb.paper_id) AS n FROM paper_benchmarks pb JOIN benchmarks b ON b.id = pb.bench_id
|
|
WHERE pb.paper_id = ANY(?) GROUP BY b.id, b.name ORDER BY n DESC, b.id LIMIT 12`, [ids])
|
|
: [];
|
|
const venues = new Map<string, number>();
|
|
for (const p of papers) venues.set(p.conf_short, (venues.get(p.conf_short) ?? 0) + 1);
|
|
|
|
return {
|
|
total: papers.length,
|
|
papers: papers.map((p) => ({ ...p, analysed: done.has(`${p.conf}/${p.ext_id}`) })),
|
|
analysed,
|
|
byVenue: [...venues].map(([conf_short, n]) => ({ conf_short, n })).sort((a, b) => b.n - a.n),
|
|
benchmarks,
|
|
};
|
|
}
|