From 1c78b906434e597476c865be2ec2c1c087328cd7 Mon Sep 17 00:00:00 2001 From: orosmatthew Date: Mon, 26 Feb 2024 19:52:47 -0500 Subject: [PATCH] [web] Implement public scoreboard with updating --- .../scoreboard/[contestId]/+page.svelte | 98 ++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/web/src/routes/public/scoreboard/[contestId]/+page.svelte b/web/src/routes/public/scoreboard/[contestId]/+page.svelte index 3240f76..6e1d815 100644 --- a/web/src/routes/public/scoreboard/[contestId]/+page.svelte +++ b/web/src/routes/public/scoreboard/[contestId]/+page.svelte @@ -2,7 +2,103 @@ import { page } from '$app/stores'; import type { PageData } from './$types'; import { contestId } from '../stores'; + import { onDestroy, onMount } from 'svelte'; + import { invalidateAll } from '$app/navigation'; $contestId = parseInt($page.params.contestId); - let data: PageData; + export let data: PageData; + + let updateInterval: ReturnType; + let updating = false; + + onMount(() => { + updateInterval = setInterval(async () => { + updating = true; + await invalidateAll(); + updating = false; + }, 10000); + }); + + onDestroy(() => { + clearInterval(updateInterval); + }); + +

{data.selected.name}

+
+
+
+ +
+ {#if updating} +
+ {/if} + Last Updated: {data.timestamp.toLocaleTimeString()} +
+ + + + + + + + + {#each data.selected.problems as problem} + + {/each} + + + + {#each data.selected.teams as team, i} + + + + + + {#each data.selected.problems as problem} + + {/each} + + {/each} + +
PlaceTeam NameSolvesTime{problem.friendlyName}
{i + 1}{team.name}{team.solves}{team.time.toFixed(0)} +
+
+ {#if team.problems.find((p) => { + return p.id === problem.id; + })?.graphic !== null} + { + return p.id === problem.id; + })?.graphic === 'correct' + ? '/correct.png' + : '/incorrect.png'} + alt="check or X" + width="30px" + /> + {/if} +
+
+ {#if team.problems.find((p) => { + return p.id === problem.id; + })?.attempts !== 0} + {team.problems.find((p) => { + return p.id === problem.id; + })?.attempts} + {team.problems.find((p) => { + return p.id === problem.id; + })?.attempts === 1 + ? 'Attempt' + : 'Attempts'}
{#if team.problems.find((p) => { + return p.id === problem.id; + })?.min}{team.problems + .find((p) => { + return p.id === problem.id; + }) + ?.min?.toFixed(0)} min{/if} + {/if} +
+
+