From c14b572038c3ccade566589056fbd303e6a3c2cf Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 29 Oct 2026 17:26:21 +0100 Subject: [PATCH] refactor(server): read the share link's journey entries through Kysely listPublicEntries changed for #2886, and the repository rules move a touched QueryBuilder call to the entity methods or Kysely. Kysely keeps the method's answer what it was, the stored row as SELECT * reads it, which the entity methods would hand back as entities with a journey reference in place of journey_id. The query-api baseline drops to 8. --- server/scripts/query-api-baseline.json | 2 +- .../repositories/JourneyEntries.repository.ts | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/server/scripts/query-api-baseline.json b/server/scripts/query-api-baseline.json index 2c7943708..2185f4108 100644 --- a/server/scripts/query-api-baseline.json +++ b/server/scripts/query-api-baseline.json @@ -15,7 +15,7 @@ "src/db/repositories/Days.repository.ts": 7, "src/db/repositories/InviteTokens.repository.ts": 3, "src/db/repositories/JourneyBooks.repository.ts": 3, - "src/db/repositories/JourneyEntries.repository.ts": 9, + "src/db/repositories/JourneyEntries.repository.ts": 8, "src/db/repositories/JourneyPhotos.repository.ts": 6, "src/db/repositories/Journeys.repository.ts": 4, "src/db/repositories/JourneyShareTokens.repository.ts": 4, diff --git a/server/src/db/repositories/JourneyEntries.repository.ts b/server/src/db/repositories/JourneyEntries.repository.ts index a21744cc2..efda72ac7 100644 --- a/server/src/db/repositories/JourneyEntries.repository.ts +++ b/server/src/db/repositories/JourneyEntries.repository.ts @@ -149,11 +149,18 @@ export class JourneyEntriesRepository extends TrekRepository { * relocated here now that it is stable. */ async listPublicEntries(journeyId: number): Promise { - return await this.qb('je') - .select(['je.*']) - .where({ journey: journeyId, type: { $ne: 'skeleton' }, dismissed: 0, is_draft: 0 }) - .orderBy({ entry_date: 'asc', sort_order: 'asc', id: 'asc' }) - .execute('all', false); + const rows = await this.kysely() + .selectFrom('journey_entries') + .selectAll() + .where('journey_id', '=', journeyId) + .where('type', '!=', 'skeleton') + .where('dismissed', '=', 0) + .where('is_draft', '=', 0) + .orderBy('entry_date', 'asc') + .orderBy('sort_order', 'asc') + .orderBy('id', 'asc') + .execute(); + return rows as JourneyEntry[]; } /** JG22 — `getJourneyFull`'s `dismissed_count`: `SELECT COUNT(*) AS n FROM journey_entries WHERE journey_id = ? AND dismissed = 1`. */