- lists read/write real lists.* tables via meta.tables/meta.columns and the SECURITY DEFINER meta functions; typed extra columns in the item forms - old numeric list URLs 308-redirect to the slug - include_recurring is boolean, osu accuracy/pp/rate numeric - raw SQL qualified with the new schemas
27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import { db } from '#lib/server/db/index.js';
|
|
import { sql } from 'drizzle-orm';
|
|
import type { PageServerLoad } from './$types';
|
|
|
|
export const load: PageServerLoad = async () => {
|
|
const [stats, dimensions, markets] = await Promise.all([
|
|
db.execute(sql`SELECT
|
|
(SELECT count(*)::int FROM cs.items) AS items,
|
|
(SELECT greatest(reltuples::bigint, 0) FROM pg_class WHERE oid = 'cs.price_observations'::regclass) AS observations,
|
|
(SELECT min(observed_at) FROM cs.price_observations) AS earliest,
|
|
(SELECT max(observed_at) FROM cs.price_observations) AS latest`),
|
|
db.execute(sql`SELECT key, count(DISTINCT value)::int AS values
|
|
FROM cs.item_dimensions GROUP BY key ORDER BY key`),
|
|
db.execute(sql`SELECT source, currency, kind FROM cs.price_streams ORDER BY 1, 2, 3`)
|
|
]);
|
|
return {
|
|
stats: stats[0] as {
|
|
items: number;
|
|
observations: string;
|
|
earliest: Date | null;
|
|
latest: Date | null;
|
|
},
|
|
dimensions: dimensions as unknown as { key: string; values: number }[],
|
|
markets: markets as unknown as { source: string; currency: string; kind: string }[]
|
|
};
|
|
};
|