segments with leaderboards, auto-matching, and popular-stretch suggestions
This commit is contained in:
@@ -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
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user