fix(acadenice): sync-block date string + graph p.slug column name — Patch 026

Two server bugs surfaced from the live test:

1. SyncBlockRepo.mapRow crashed with 'Cannot read properties of
   undefined (reading toISOString)' on POST /api/acadenice/sync-blocks.
   The kysely-postgres-js driver returns timestamps as strings, not
   Date instances. Wrap with new Date(...) before .toISOString().

2. GraphService.loadPageMeta + loadOrphanPages SELECT'd p.slug, but the
   native pages table column is named slug_id. Postgres rejected the
   query, the catch returned [], and the graph rendered empty even when
   pages existed. Aliased p.slug_id AS slug to match the PageMetaRow
   interface.

Patch 026.
This commit is contained in:
Corentin JOGUET 2026-05-08 12:47:12 +02:00
parent 9b33a2683b
commit 7fba3c0452
2 changed files with 6 additions and 6 deletions

View file

@ -434,7 +434,7 @@ export class GraphService {
SELECT SELECT
p.id, p.id,
p.title, p.title,
p.slug, p.slug_id AS slug,
p.space_id, p.space_id,
sp.name AS space_name, sp.name AS space_name,
p.icon p.icon
@ -479,7 +479,7 @@ export class GraphService {
SELECT SELECT
p.id, p.id,
p.title, p.title,
p.slug, p.slug_id AS slug,
p.space_id, p.space_id,
sp.name AS space_name, sp.name AS space_name,
p.icon p.icon

View file

@ -181,16 +181,16 @@ export class SyncBlockRepo {
workspace_id: string; workspace_id: string;
content: Record<string, unknown>; content: Record<string, unknown>;
created_by: string; created_by: string;
created_at: Date; created_at: Date | string;
updated_at: Date; updated_at: Date | string;
}): SyncBlockResponseDto { }): SyncBlockResponseDto {
return { return {
id: row.id, id: row.id,
workspaceId: row.workspace_id, workspaceId: row.workspace_id,
content: row.content, content: row.content,
createdBy: row.created_by, createdBy: row.created_by,
createdAt: row.created_at.toISOString(), createdAt: new Date(row.created_at).toISOString(),
updatedAt: row.updated_at.toISOString(), updatedAt: new Date(row.updated_at).toISOString(),
}; };
} }
} }