9ffe734275
Deploy / deploy (push) Successful in 7m40s
- /api/articles[/slug]: GET/PUT/POST/DELETE, article JSON stored in PostgreSQL (schema analysis) - /api/tool-taxonomy: categories (tree), per-paper tools, each tool in one or more categories - /contents/tools-of-agents: category table with roll-up and links to the papers; removed "By kind of contribution" and "Recent papers" - content moves out of the repo: removed content/articles, load-articles.js, agent-tools.ts Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FbMbJPadPzVwvt9rU9GBNo
27 lines
1.3 KiB
TypeScript
27 lines
1.3 KiB
TypeScript
import { one, query } from './db';
|
|
import { listReviews } from './reviews';
|
|
import { Area } from './worktypes';
|
|
import type { ContentNode } from './content-tree';
|
|
|
|
export async function getContent(node: ContentNode) {
|
|
const areas = await query<Area>('SELECT a.*, 0 AS n FROM areas a WHERE a.id = ANY(?) ORDER BY sort', [node.areas]);
|
|
const [benchmarks, taxonomy, total, reviews] = await Promise.all([
|
|
query<{ id: number; name: string; n: number; n_new: number }>(
|
|
`SELECT b.id, b.name, COUNT(DISTINCT pb.paper_id) AS n, SUM(pb.is_new) AS n_new
|
|
FROM paper_benchmarks pb JOIN benchmarks b ON b.id = pb.bench_id JOIN paper_work_types w ON w.paper_id = pb.paper_id
|
|
WHERE split_part(w.type_id,'|',1) = ANY(?) GROUP BY b.id ORDER BY n DESC, b.id LIMIT 12`, [node.areas]),
|
|
query<{ id: string; label: string; n: number }>(
|
|
`SELECT pt.node_id AS id, t.label, COUNT(DISTINCT pt.paper_id) AS n FROM paper_taxonomy pt JOIN taxonomy t ON t.id = pt.node_id
|
|
WHERE pt.node_id = ANY(?) GROUP BY pt.node_id, t.label`, [node.taxonomy]),
|
|
one<{ n: number }>(`SELECT COUNT(DISTINCT paper_id) AS n FROM paper_work_types WHERE split_part(type_id,'|',1) = ANY(?)`, [node.areas]),
|
|
listReviews(),
|
|
]);
|
|
return {
|
|
areas,
|
|
total: total?.n ?? 0,
|
|
benchmarks,
|
|
taxonomy,
|
|
reviews: reviews.filter((r) => node.areas.includes(r.area)),
|
|
};
|
|
}
|