From d1975ccabade602aec360e2ea23e74eecf1b1bf5 Mon Sep 17 00:00:00 2001 From: Henry Fontanier Date: Mon, 29 Jul 2024 14:04:08 +0200 Subject: [PATCH] fix: remove where clause from notion GC (#6565) Co-authored-by: Henry Fontanier --- .../src/connectors/notion/temporal/activities.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/connectors/src/connectors/notion/temporal/activities.ts b/connectors/src/connectors/notion/temporal/activities.ts index 156c2a0fd8ec..74db7a6545c0 100644 --- a/connectors/src/connectors/notion/temporal/activities.ts +++ b/connectors/src/connectors/notion/temporal/activities.ts @@ -820,8 +820,7 @@ export async function garbageCollect({ do { // Find the resources not seen in the GC run (using runTimestamp). resourcesToCheck = await findResourcesNotSeenInGarbageCollectionRun( - connector.id, - runTimestamp + connector.id ); const NOTION_UNHEALTHY_ERROR_CODES = [ @@ -1074,8 +1073,7 @@ export async function deletePageOrDatabaseIfArchived({ } async function findResourcesNotSeenInGarbageCollectionRun( - connectorId: ModelId, - runTimestamp: number + connectorId: ModelId ): Promise< Array<{ lastSeenTs: Date; @@ -1114,10 +1112,8 @@ async function findResourcesNotSeenInGarbageCollectionRun( await NotionPage.findAll({ where: { connectorId, - lastSeenTs: { - [Op.lt]: new Date(runTimestamp), - }, }, + order: [["lastSeenTs", "ASC"]], attributes: ["lastSeenTs", "notionPageId", "skipReason"], limit: pageSize, }) @@ -1142,10 +1138,8 @@ async function findResourcesNotSeenInGarbageCollectionRun( await NotionDatabase.findAll({ where: { connectorId, - lastSeenTs: { - [Op.lt]: new Date(runTimestamp), - }, }, + order: [["lastSeenTs", "ASC"]], attributes: ["lastSeenTs", "notionDatabaseId", "skipReason"], limit: pageSize, })