fixes stats page activity limit

This commit is contained in:
Christian Beutel
2025-04-11 14:32:52 +02:00
parent 5790da2317
commit 6bf419b98e
4 changed files with 20 additions and 27 deletions

View File

@@ -9,6 +9,7 @@
import * as M from "maplibre-gl"; import * as M from "maplibre-gl";
import { _ } from "svelte-i18n"; import { _ } from "svelte-i18n";
import MapWithElevationMaplibre from "../trail/map_with_elevation_maplibre.svelte"; import MapWithElevationMaplibre from "../trail/map_with_elevation_maplibre.svelte";
import { fetchGPX } from "$lib/stores/trail_store";
interface Props { interface Props {
summitLogs?: SummitLog[]; summitLogs?: SummitLog[];
@@ -41,10 +42,14 @@
async function openMap(log: SummitLog) { async function openMap(log: SummitLog) {
if (!log.expand?.gpx_data) { if (!log.expand?.gpx_data) {
return; const gpxData: string = await fetchGPX(log as any, fetch);
log.expand = {
...(log.expand ?? {}),
gpx_data: gpxData,
};
} }
trail = (await gpx2trail(log.expand.gpx_data)).trail; trail = (await gpx2trail(log.expand.gpx_data!)).trail;
trail.id = log.id; trail.id = log.id;
trail.expand!.gpx_data = log.expand.gpx_data; trail.expand!.gpx_data = log.expand.gpx_data;
@@ -124,10 +129,7 @@
{#snippet content()} {#snippet content()}
<div id="summit-log-table-map" class="h-[32rem]"> <div id="summit-log-table-map" class="h-[32rem]">
{#if trail} {#if trail}
<MapWithElevationMaplibre <MapWithElevationMaplibre trails={[trail]} bind:map showTerrain
trails={[trail]}
bind:map
showTerrain
></MapWithElevationMaplibre> ></MapWithElevationMaplibre>
{/if} {/if}
</div> </div>

View File

@@ -192,7 +192,7 @@
</p> </p>
</td> </td>
{/if} {/if}
{#if showRoute && log.expand?.gpx_data} {#if showRoute && log.gpx}
<td> <td>
<button <button
aria-label="Open route" aria-label="Open route"

View File

@@ -15,6 +15,7 @@ export async function summit_logs_index(author: string, filter?: SummitLogFilter
const r = await f('/api/v1/summit-log?' + new URLSearchParams({ const r = await f('/api/v1/summit-log?' + new URLSearchParams({
filter: filterText, filter: filterText,
perPage: "-1",
expand: "trails_via_summit_logs.category", expand: "trails_via_summit_logs.category",
sort: "+date", sort: "+date",
}), { }), {
@@ -28,17 +29,17 @@ export async function summit_logs_index(author: string, filter?: SummitLogFilter
const fetchedSummitLogs: ListResult<SummitLog> = await r.json(); const fetchedSummitLogs: ListResult<SummitLog> = await r.json();
for (const log of fetchedSummitLogs.items) { // for (const log of fetchedSummitLogs.items) {
if (!log.gpx) { // if (!log.gpx) {
continue // continue
} // }
const gpxData: string = await fetchGPX(log as any, f); // const gpxData: string = await fetchGPX(log as any, f);
if (!log.expand) { // if (!log.expand) {
log.expand = {}; // log.expand = {};
} // }
log.expand.gpx_data = gpxData; // log.expand.gpx_data = gpxData;
} // }
summitLogs.set(fetchedSummitLogs.items); summitLogs.set(fetchedSummitLogs.items);

View File

@@ -1,6 +1,5 @@
import { SummitLogCreateSchema } from '$lib/models/api/summit_log_schema'; import { SummitLogCreateSchema } from '$lib/models/api/summit_log_schema';
import type { SummitLog } from '$lib/models/summit_log'; import type { SummitLog } from '$lib/models/summit_log';
import { pb } from '$lib/pocketbase';
import { Collection, create, handleError, list } from '$lib/util/api_util'; import { Collection, create, handleError, list } from '$lib/util/api_util';
import { json, type RequestEvent } from '@sveltejs/kit'; import { json, type RequestEvent } from '@sveltejs/kit';
@@ -8,15 +7,6 @@ export async function GET(event: RequestEvent) {
try { try {
const r = await list<SummitLog>(event, Collection.summit_logs); const r = await list<SummitLog>(event, Collection.summit_logs);
for (const t of r.items) {
if (!t.author || !pb.authStore.record) {
continue;
}
if (!t.expand) {
t.expand = {} as any
}
t.expand!.author = await pb.collection("users_anonymous").getOne(t.author);
}
return json(r) return json(r)
} catch (e: any) { } catch (e: any) {
throw handleError(e); throw handleError(e);