diff --git a/frontend/src/models/schemas.ts b/frontend/src/models/schemas.ts index 4d75f17..946e1bc 100644 --- a/frontend/src/models/schemas.ts +++ b/frontend/src/models/schemas.ts @@ -59,5 +59,7 @@ export interface WhoResponse { role: UserRoleEnum } export interface VisitStats { + bar_visits_by_area: [string, number][] distinct_bar_visits: number + total_bars_by_area: [string, number][] } diff --git a/frontend/src/routes/me/+page.svelte b/frontend/src/routes/me/+page.svelte index 77a3c30..39febae 100644 --- a/frontend/src/routes/me/+page.svelte +++ b/frontend/src/routes/me/+page.svelte @@ -15,6 +15,14 @@ }) } + function zipVistsByArea(total_bars: [string, number][], visit_bars: [string, number][]) { + let areaMap = new Map() + // zip two array together using map: a.map((k, i) => [k, b[i]]) + // this assumes that the two arrays are sorted in the same order + total_bars.map((k, i) => areaMap.set(k[0], [k[1], visit_bars[i][1]])) + return areaMap + } + onMount(async () => { get_bar_visit_stats() .then((response) => { @@ -42,17 +50,33 @@

This could've been you.

Uhuh not sure who you are, are you even logged in?

{/if} - +

Statistics

{#if visitStats && userData} -

Visits:

- + Total bars visited: {visitStats.distinct_bar_visits} + + + + + + + + + + + {#each zipVistsByArea(visitStats.total_bars_by_area, visitStats.bar_visits_by_area).entries() as [name, [total, count]]} + + + + + + {/each} + +
AreaTotalVisits
{name}{total}{count}
{:else if userData}

Fetching visit stats...

{/if} - +

Management

{#if userData} {/if}