Skip to content

Commit bdcfce5

Browse files
committed
add effect
1 parent 79f9dab commit bdcfce5

13 files changed

Lines changed: 600 additions & 444 deletions

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
3333
# Finder (MacOS) folder config
3434
.DS_Store
3535
*.sqlite
36+
.direnv/

.prettierrc.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

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: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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() {

flake.lock

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

flake.nix

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
4+
};
5+
outputs = {nixpkgs, ...}: let
6+
forAllSystems = function:
7+
nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (
8+
system: function nixpkgs.legacyPackages.${system}
9+
);
10+
in {
11+
formatter = forAllSystems (pkgs: pkgs.alejandra);
12+
devShells = forAllSystems (pkgs: {
13+
default = pkgs.mkShell {
14+
packages = with pkgs; [
15+
bun
16+
corepack
17+
nodejs
18+
];
19+
};
20+
});
21+
};
22+
}

0 commit comments

Comments
 (0)