From 7fba3c04528014555efb41c027f559904f756066 Mon Sep 17 00:00:00 2001 From: Corentin Date: Fri, 8 May 2026 12:47:12 +0200 Subject: [PATCH] =?UTF-8?q?fix(acadenice):=20sync-block=20date=20string=20?= =?UTF-8?q?+=20graph=20p.slug=20column=20name=20=E2=80=94=20Patch=20026?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../src/core/acadenice/graph/services/graph.service.ts | 4 ++-- .../core/acadenice/sync-blocks/repos/sync-block.repo.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/server/src/core/acadenice/graph/services/graph.service.ts b/apps/server/src/core/acadenice/graph/services/graph.service.ts index 960b9a65..06081afd 100644 --- a/apps/server/src/core/acadenice/graph/services/graph.service.ts +++ b/apps/server/src/core/acadenice/graph/services/graph.service.ts @@ -434,7 +434,7 @@ export class GraphService { SELECT p.id, p.title, - p.slug, + p.slug_id AS slug, p.space_id, sp.name AS space_name, p.icon @@ -479,7 +479,7 @@ export class GraphService { SELECT p.id, p.title, - p.slug, + p.slug_id AS slug, p.space_id, sp.name AS space_name, p.icon diff --git a/apps/server/src/core/acadenice/sync-blocks/repos/sync-block.repo.ts b/apps/server/src/core/acadenice/sync-blocks/repos/sync-block.repo.ts index b2cf4069..6a276856 100644 --- a/apps/server/src/core/acadenice/sync-blocks/repos/sync-block.repo.ts +++ b/apps/server/src/core/acadenice/sync-blocks/repos/sync-block.repo.ts @@ -181,16 +181,16 @@ export class SyncBlockRepo { workspace_id: string; content: Record; created_by: string; - created_at: Date; - updated_at: Date; + created_at: Date | string; + updated_at: Date | string; }): SyncBlockResponseDto { return { id: row.id, workspaceId: row.workspace_id, content: row.content, createdBy: row.created_by, - createdAt: row.created_at.toISOString(), - updatedAt: row.updated_at.toISOString(), + createdAt: new Date(row.created_at).toISOString(), + updatedAt: new Date(row.updated_at).toISOString(), }; } }