logo, fix db loading

This commit is contained in:
Theo Browne
2026-02-20 04:49:40 -08:00
parent 593ad125ff
commit 77f68d440c
9 changed files with 656 additions and 720 deletions

7
db.ts
View File

@@ -21,7 +21,7 @@ export function saveRound(round: RoundState) {
export function getRounds(page: number = 1, limit: number = 10) {
const offset = (page - 1) * limit;
const countQuery = db.query("SELECT COUNT(*) as count FROM rounds").get() as { count: number };
const rows = db.query("SELECT data FROM rounds ORDER BY id DESC LIMIT $limit OFFSET $offset")
const rows = db.query("SELECT data FROM rounds ORDER BY num DESC, id DESC LIMIT $limit OFFSET $offset")
.all({ $limit: limit, $offset: offset }) as { data: string }[];
return {
rounds: rows.map(r => JSON.parse(r.data) as RoundState),
@@ -31,3 +31,8 @@ export function getRounds(page: number = 1, limit: number = 10) {
totalPages: Math.ceil(countQuery.count / limit)
};
}
export function getAllRounds() {
const rows = db.query("SELECT data FROM rounds ORDER BY num ASC, id ASC").all() as { data: string }[];
return rows.map(r => JSON.parse(r.data) as RoundState);
}