diff --git a/.gitignore b/.gitignore index 66891d6..6f14e65 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ vite.config.ts.timestamp-* *.db .session scripts/data/* +.session diff --git a/.session b/.session deleted file mode 100644 index 1064f59..0000000 --- a/.session +++ /dev/null @@ -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(":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(":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 : diff --git a/scripts/seed.ts b/scripts/seed.ts index 5eaa933..7f1df63 100644 --- a/scripts/seed.ts +++ b/scripts/seed.ts @@ -148,20 +148,22 @@ async function seed() { for (const row of eventAttributionsCSV) { const eventId = eventMap.get(row.eventID); const playerId = playerMap.get(row.playerID); + const placement = parseInt(row.placement); if (!eventId) throw new Error(`Event "${row.eventID}" not found`); if (!playerId) throw new Error(`Player "${row.playerID}" not found`); + if (placement <= 0) continue; const result = await db .insert(schema.eventAttributions) .values({ eventID: eventId, playerID: playerId, - placement: 0 + placement }) .returning(); console.log( - ` Inserted attribution: event=${row.eventID}, player=${row.playerID}, placement=0 (blank)` + ` Inserted attribution: event=${row.eventID}, player=${row.playerID}, placement=${placement}` ); } diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 453b8a4..e2b3485 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -1,5 +1,5 @@ import { db } from '$lib/server/db'; -import { houses } from '$lib/server/db/schema'; +import * as schema from '$lib/server/db/schema'; export class House { name: string = ''; @@ -8,14 +8,14 @@ export class House { } export const load = async () => { - const allHouses = await db.select().from(houses); - console.log(allHouses); + const allTeams = await db.select().from(schema.teamScoresView); + console.log(allTeams); return { - houses: allHouses.map((house) => ({ - ...house, - name: house.name, - color: house.color, - points: house.points + teams: allTeams.map((team) => ({ + ...team, + name: team.teamName, + color: team.teamColor, + points: team.totalPoints || 0 })) }; }; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 58a3abe..69d3d7c 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -2,24 +2,7 @@ import type { PageData } from './$types'; let { data }: { data: import('./$types').PageData } = $props(); - // const housesArr: string[][] = [ - // ['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)); + let leaderboard = $derived([...data.teams].sort((a, b) => b.points - a.points));