Skip to content

Commit e38348c

Browse files
committed
wip
1 parent f1033d0 commit e38348c

6 files changed

Lines changed: 216 additions & 110 deletions

File tree

CLAUDE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,9 @@ bun --hot ./index.ts
109109
```
110110

111111
For more information, read the Bun API docs in `node_modules/bun-types/docs/**.mdx`.
112+
113+
## Learning about "effect"
114+
115+
The source code is available at `.repos/effect`
116+
117+
Use this instead of node_modules

bun.lock

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

db.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Database } from "bun:sqlite";
2-
import type { RoundState } from "./game.ts";
2+
import type { RoundState } from "./game-effect.ts";
33

44
const dbPath = process.env.DATABASE_PATH ?? "quipslop.sqlite";
55
export const db = new Database(dbPath, { create: true });
@@ -14,27 +14,36 @@ db.exec(`
1414
`);
1515

1616
export function saveRound(round: RoundState) {
17-
const insert = db.prepare("INSERT INTO rounds (num, data) VALUES ($num, $data)");
17+
const insert = db.prepare(
18+
"INSERT INTO rounds (num, data) VALUES ($num, $data)",
19+
);
1820
insert.run({ $num: round.num, $data: JSON.stringify(round) });
1921
}
2022

2123
export function getRounds(page: number = 1, limit: number = 10) {
2224
const offset = (page - 1) * limit;
23-
const countQuery = db.query("SELECT COUNT(*) as count FROM rounds").get() as { count: number };
24-
const rows = db.query("SELECT data FROM rounds ORDER BY num DESC, id DESC LIMIT $limit OFFSET $offset")
25+
const countQuery = db.query("SELECT COUNT(*) as count FROM rounds").get() as {
26+
count: number;
27+
};
28+
const rows = db
29+
.query(
30+
"SELECT data FROM rounds ORDER BY num DESC, id DESC LIMIT $limit OFFSET $offset",
31+
)
2532
.all({ $limit: limit, $offset: offset }) as { data: string }[];
2633
return {
27-
rounds: rows.map(r => JSON.parse(r.data) as RoundState),
34+
rounds: rows.map((r) => JSON.parse(r.data) as RoundState),
2835
total: countQuery.count,
2936
page,
3037
limit,
31-
totalPages: Math.ceil(countQuery.count / limit)
38+
totalPages: Math.ceil(countQuery.count / limit),
3239
};
3340
}
3441

3542
export function getAllRounds() {
36-
const rows = db.query("SELECT data FROM rounds ORDER BY num ASC, id ASC").all() as { data: string }[];
37-
return rows.map(r => JSON.parse(r.data) as RoundState);
43+
const rows = db
44+
.query("SELECT data FROM rounds ORDER BY num ASC, id ASC")
45+
.all() as { data: string }[];
46+
return rows.map((r) => JSON.parse(r.data) as RoundState);
3847
}
3948

4049
export function clearAllRounds() {

0 commit comments

Comments
 (0)