diff --git a/src/lib/server/eventManager.ts b/src/lib/server/eventManager.ts index 24a5dfd..4d9b5b9 100644 --- a/src/lib/server/eventManager.ts +++ b/src/lib/server/eventManager.ts @@ -3,20 +3,18 @@ import { db } from '$lib/server/db'; import { eq } from 'drizzle-orm'; import * as schema from '$lib/server/db/schema'; -let testScore = 0; - // Emitter that emits export const globalEmitter = new EventEmitter(); +//// REFERENCE CODE // Increment score for testing (remove ts) -const increment = () => { - testScore++; - console.log('score incremented', testScore); - globalEmitter.emit('scoreUpdate'); -}; - +// const increment = () => { +// testScore++; +// console.log('score incremented', testScore); +// globalEmitter.emit('scoreUpdate'); +// }; // Increment scores when there is an emit -globalEmitter.on('incrementScores', increment); +// globalEmitter.on('incrementScores', increment); // For page.server.ts so that it doesnt look weird before loading export async function getAllInitialInfo() { @@ -29,11 +27,17 @@ export async function getAllInitialInfo() { // Get teams object from database export async function getTeams() { const allTeams = await db.select().from(schema.teamScoresView); + for (let team in allTeams) { + let currentTeam = allTeams[team]; + if (!currentTeam.totalPoints) { + currentTeam.totalPoints = 0; + } + } return { teams: allTeams.map((team) => ({ name: team.teamName, color: team.teamColor, - points: team.totalPoints || testScore + points: team.totalPoints })) }; } diff --git a/src/lib/ui/Table.svelte b/src/lib/ui/Table.svelte new file mode 100644 index 0000000..ae4c5af --- /dev/null +++ b/src/lib/ui/Table.svelte @@ -0,0 +1,90 @@ + + +