Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

refactor(server): read the share link's journey entries through Kysely

Mauricec14b572038c3
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<JourneyEntries> {
* relocated here now that it is stable.
*/
async listPublicEntries(journeyId: number): Promise<JourneyEntry[]> {
- 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<JourneyEntry[]>('all', false);
+ const rows = await this.kysely<JourneyEntriesDateSortKyselyDB>()
+ .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`. */