segments with leaderboards, auto-matching, and popular-stretch suggestions

This commit is contained in:
Vincent van der Wal
2026-07-22 16:17:26 +02:00
parent 91775c4099
commit da9f7c6e1a
14 changed files with 930 additions and 4 deletions
+17
View File
@@ -0,0 +1,17 @@
import { error } from '@sveltejs/kit';
import { getSegment, segmentLeaderboard } from '$lib/server/db';
import type { PageServerLoad } from './$types';
import type { TrackPt } from '$lib/server/segments';
export const load: PageServerLoad = ({ params, locals }) => {
const segment = getSegment(Number(params.id));
if (!segment) error(404, 'Segment not found');
const points = JSON.parse(segment.points) as TrackPt[];
return {
segment: { ...segment, points: undefined },
latlngs: points.map((p) => [p.lat, p.lon] as [number, number]),
leaderboard: segmentLeaderboard(segment.id),
myUserId: locals.user?.id ?? null
};
};