From 6cbba8c3375997a2132c8c5febeadbd765a2d8da Mon Sep 17 00:00:00 2001 From: Hsu Zhong Jun <27919917+dcshzj@users.noreply.github.com> Date: Tue, 7 Jan 2025 11:54:30 +0800 Subject: [PATCH] fix: use updatedAt column for last updated date (#975) --- tooling/build/scripts/publishing/index.ts | 2 +- tooling/build/scripts/publishing/queries.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tooling/build/scripts/publishing/index.ts b/tooling/build/scripts/publishing/index.ts index afba54ee9..7180b7340 100644 --- a/tooling/build/scripts/publishing/index.ts +++ b/tooling/build/scripts/publishing/index.ts @@ -124,7 +124,7 @@ async function main() { type: resource.type, title: resource.title, permalink: `/${getConvertedPermalink(resource.fullPermalink)}`, - lastModified: new Date().toISOString(), // TODO: Update to updated_at column + lastModified: resource.updatedAt.toISOString(), layout: resource.content.layout || "content", summary: (Array.isArray(resource.content.page.contentPageHeader?.summary) diff --git a/tooling/build/scripts/publishing/queries.ts b/tooling/build/scripts/publishing/queries.ts index d9a1ea42d..f524aabe4 100644 --- a/tooling/build/scripts/publishing/queries.ts +++ b/tooling/build/scripts/publishing/queries.ts @@ -1,5 +1,5 @@ export const GET_ALL_RESOURCES_WITH_FULL_PERMALINKS = ` -WITH RECURSIVE "resourcePath" (id, title, permalink, parentId, type, content, "fullPermalink", "publishedVersionId") AS ( +WITH RECURSIVE "resourcePath" (id, title, permalink, parentId, type, content, "fullPermalink", "publishedVersionId", "updatedAt") AS ( -- Base case for all resources SELECT r.id, @@ -12,7 +12,8 @@ WITH RECURSIVE "resourcePath" (id, title, permalink, parentId, type, content, "f ELSE NULL END AS content, r.permalink AS "fullPermalink", - r."publishedVersionId" + r."publishedVersionId", + r."updatedAt" FROM public."Resource" r LEFT JOIN public."Version" v ON v."id" = r."publishedVersionId" @@ -34,7 +35,8 @@ WITH RECURSIVE "resourcePath" (id, title, permalink, parentId, type, content, "f ELSE NULL END AS content, CONCAT(path."fullPermalink", '/', r.permalink) AS "fullPermalink", - r."publishedVersionId" + r."publishedVersionId", + r."updatedAt" FROM public."Resource" r LEFT JOIN public."Version" v ON v."id" = r."publishedVersionId"