main screen works again, will come back to database.
duplicated placement data in the attribution table and the ledger scores table. Means that setting placement in the attribution table is meaningless. Probably best to remove the placement in the attribution, or have it reference the placement in the ledger, else return 0. That would mean that the only way to change the scores is in the ledger, which is basically what I want, but also if the db dies then there's not really anything that I can do to recover the scores (same is true for the attribute table, but I can seed that so it doesn't matter as much). To get around that, I would need to add seeding the ledger to a seperate command, which defeats the point of a ledger. Just add a way to import and export the whole ledger to csv, dumbass.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -25,3 +25,4 @@ vite.config.ts.timestamp-*
|
|||||||
*.db
|
*.db
|
||||||
.session
|
.session
|
||||||
scripts/data/*
|
scripts/data/*
|
||||||
|
.session
|
||||||
|
|||||||
63
.session
63
.session
@@ -1,63 +0,0 @@
|
|||||||
let SessionLoad = 1
|
|
||||||
let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1
|
|
||||||
let v:this_session=expand("<sfile>:p")
|
|
||||||
doautoall SessionLoadPre
|
|
||||||
silent only
|
|
||||||
silent tabonly
|
|
||||||
cd ~/Documents/projects/score-system
|
|
||||||
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
|
|
||||||
let s:wipebuf = bufnr('%')
|
|
||||||
endif
|
|
||||||
let s:shortmess_save = &shortmess
|
|
||||||
set shortmess+=aoO
|
|
||||||
badd +1 src/routes/layout.css
|
|
||||||
badd +10 src/routes/+layout.svelte
|
|
||||||
badd +9 src/app.html
|
|
||||||
badd +22 src/routes/+page.svelte
|
|
||||||
badd +50 health://
|
|
||||||
badd +27 flake.nix
|
|
||||||
badd +57 src/lib/server/db/schema.ts
|
|
||||||
badd +1 src/lib/server/db/index.ts
|
|
||||||
badd +104 src/lib/server/db/auth.schema.ts
|
|
||||||
badd +17 src/routes/+page.server.ts
|
|
||||||
badd +1 src/hooks.server.ts
|
|
||||||
badd +1 scripts/seed.ts
|
|
||||||
badd +8 tsconfig.json
|
|
||||||
badd +1 drizzle.config.ts
|
|
||||||
argglobal
|
|
||||||
%argdel
|
|
||||||
edit drizzle.config.ts
|
|
||||||
argglobal
|
|
||||||
balt src/lib/server/db/schema.ts
|
|
||||||
setlocal foldmethod=manual
|
|
||||||
setlocal foldexpr=0
|
|
||||||
setlocal foldmarker={{{,}}}
|
|
||||||
setlocal foldignore=#
|
|
||||||
setlocal foldlevel=0
|
|
||||||
setlocal foldminlines=1
|
|
||||||
setlocal foldnestmax=20
|
|
||||||
setlocal foldenable
|
|
||||||
silent! normal! zE
|
|
||||||
let &fdl = &fdl
|
|
||||||
let s:l = 1 - ((0 * winheight(0) + 27) / 54)
|
|
||||||
if s:l < 1 | let s:l = 1 | endif
|
|
||||||
keepjumps exe s:l
|
|
||||||
normal! zt
|
|
||||||
keepjumps 1
|
|
||||||
normal! 0
|
|
||||||
tabnext 1
|
|
||||||
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
|
|
||||||
silent exe 'bwipe ' . s:wipebuf
|
|
||||||
endif
|
|
||||||
unlet! s:wipebuf
|
|
||||||
set winheight=1 winwidth=20
|
|
||||||
let &shortmess = s:shortmess_save
|
|
||||||
let s:sx = expand("<sfile>:p:r")."x.vim"
|
|
||||||
if filereadable(s:sx)
|
|
||||||
exe "source " . fnameescape(s:sx)
|
|
||||||
endif
|
|
||||||
let &g:so = s:so_save | let &g:siso = s:siso_save
|
|
||||||
nohlsearch
|
|
||||||
doautoall SessionLoadPost
|
|
||||||
unlet SessionLoad
|
|
||||||
" vim: set ft=vim :
|
|
||||||
@@ -148,20 +148,22 @@ async function seed() {
|
|||||||
for (const row of eventAttributionsCSV) {
|
for (const row of eventAttributionsCSV) {
|
||||||
const eventId = eventMap.get(row.eventID);
|
const eventId = eventMap.get(row.eventID);
|
||||||
const playerId = playerMap.get(row.playerID);
|
const playerId = playerMap.get(row.playerID);
|
||||||
|
const placement = parseInt(row.placement);
|
||||||
|
|
||||||
if (!eventId) throw new Error(`Event "${row.eventID}" not found`);
|
if (!eventId) throw new Error(`Event "${row.eventID}" not found`);
|
||||||
if (!playerId) throw new Error(`Player "${row.playerID}" not found`);
|
if (!playerId) throw new Error(`Player "${row.playerID}" not found`);
|
||||||
|
if (placement <= 0) continue;
|
||||||
|
|
||||||
const result = await db
|
const result = await db
|
||||||
.insert(schema.eventAttributions)
|
.insert(schema.eventAttributions)
|
||||||
.values({
|
.values({
|
||||||
eventID: eventId,
|
eventID: eventId,
|
||||||
playerID: playerId,
|
playerID: playerId,
|
||||||
placement: 0
|
placement
|
||||||
})
|
})
|
||||||
.returning();
|
.returning();
|
||||||
console.log(
|
console.log(
|
||||||
` Inserted attribution: event=${row.eventID}, player=${row.playerID}, placement=0 (blank)`
|
` Inserted attribution: event=${row.eventID}, player=${row.playerID}, placement=${placement}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { db } from '$lib/server/db';
|
import { db } from '$lib/server/db';
|
||||||
import { houses } from '$lib/server/db/schema';
|
import * as schema from '$lib/server/db/schema';
|
||||||
|
|
||||||
export class House {
|
export class House {
|
||||||
name: string = '';
|
name: string = '';
|
||||||
@@ -8,14 +8,14 @@ export class House {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const load = async () => {
|
export const load = async () => {
|
||||||
const allHouses = await db.select().from(houses);
|
const allTeams = await db.select().from(schema.teamScoresView);
|
||||||
console.log(allHouses);
|
console.log(allTeams);
|
||||||
return {
|
return {
|
||||||
houses: allHouses.map((house) => ({
|
teams: allTeams.map((team) => ({
|
||||||
...house,
|
...team,
|
||||||
name: house.name,
|
name: team.teamName,
|
||||||
color: house.color,
|
color: team.teamColor,
|
||||||
points: house.points
|
points: team.totalPoints || 0
|
||||||
}))
|
}))
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,24 +2,7 @@
|
|||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
let { data }: { data: import('./$types').PageData } = $props();
|
let { data }: { data: import('./$types').PageData } = $props();
|
||||||
|
|
||||||
// const housesArr: string[][] = [
|
let leaderboard = $derived([...data.teams].sort((a, b) => b.points - a.points));
|
||||||
// ['county', 'red'],
|
|
||||||
// ['east', 'pink'],
|
|
||||||
// ['laud', 'teal'],
|
|
||||||
// ['school', 'green'],
|
|
||||||
// ['west', 'yellow']
|
|
||||||
// ];
|
|
||||||
|
|
||||||
// let houses: House[] = [];
|
|
||||||
|
|
||||||
// housesArr.forEach((value: string[]) => {
|
|
||||||
// let newHouse = new House();
|
|
||||||
// newHouse.name = value[0];
|
|
||||||
// newHouse.color = `var(--ctp-mocha-${value[1]})`;
|
|
||||||
// houses.push(newHouse);
|
|
||||||
// });
|
|
||||||
|
|
||||||
let leaderboard = $derived([...data.houses].sort((a, b) => b.points - a.points));
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in New Issue
Block a user