CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/lib/landing/stats.ts
Views: 687
1
import getPool from "@cocalc/database/pool";
2
import { Stats } from "@cocalc/util/db-schema/stats";
3
4
// Returns undefined if no stats data is available.
5
export default async function getStats(): Promise<Stats | undefined> {
6
const pool = getPool('long');
7
const result = await pool.query(
8
"SELECT * FROM stats ORDER BY time DESC LIMIT 1"
9
);
10
if (result.rows.length == 0) return;
11
const data = result.rows[0];
12
data.time = data.time.valueOf();
13
return data;
14
}
15
16