feat(hunt): track walking distance via GPS, show live locations on map
Docker Image CI / test (push) Failing after 41s
Docker Image CI / deploy (push) Skipped
Tests / unit (push) Failing after 36s
Tests / integration (push) Successful in 1m34s

Add foreground-only GPS distance tracking for hunts
This commit is contained in:
2026-09-27 20:55:58 +02:00
parent a0fc836c05
commit 61cc516f47
43 changed files with 2313 additions and 24 deletions
+38 -1
View File
@@ -3,7 +3,7 @@ import prisma from '~~/lib/prisma';
export default defineEventHandler(async (event) => {
const user = await requireUserSession(event);
return prisma.user.findUnique({
const profile = await prisma.user.findUnique({
where: { id: user.user.id },
select: {
name: true,
@@ -38,7 +38,44 @@ export default defineEventHandler(async (event) => {
answerId: null
}
}
},
userTracks: {
select: {
distanceMeters: true,
hunt: {
select: {
id: true,
name_de: true,
name_en: true
}
}
},
where: {
hunt: {
deletedAt: null
}
}
}
}
});
if (!profile) {
throw createError({ status: 404, statusText: 'Not found!' });
}
const { userTracks, ...rest } = profile;
const distances = userTracks.map((track) => ({
huntId: track.hunt.id,
huntName_de: track.hunt.name_de,
huntName_en: track.hunt.name_en,
distanceMeters: track.distanceMeters
}));
const totalDistance = distances.reduce(
(sum, entry) => sum + entry.distanceMeters,
0
);
return { ...rest, distances, totalDistance };
});