From ee968b212a4b0c4da13cef3859a2d8526e95b998 Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 9 Sep 2024 16:10:39 +0100 Subject: [PATCH] Fix to accommodate filtering updates for GoogleSheets --- packages/server/src/integrations/googlesheets.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/server/src/integrations/googlesheets.ts b/packages/server/src/integrations/googlesheets.ts index f8f5209890..ea62281d4b 100644 --- a/packages/server/src/integrations/googlesheets.ts +++ b/packages/server/src/integrations/googlesheets.ts @@ -566,24 +566,20 @@ class GoogleSheetsIntegration implements DatasourcePlus { query.filters.equal[`_${GOOGLE_SHEETS_PRIMARY_KEY}`] = id } } - let filtered = dataFilters.runQuery( - rows, - query.filters || {}, - (row: GoogleSpreadsheetRow, headerKey: string) => { - return row.get(headerKey) - } - ) + if (hasFilters && query.paginate) { - filtered = filtered.slice(offset, offset + limit) + rows = rows.slice(offset, offset + limit) } const headerValues = sheet.headerValues let response = [] - for (let row of filtered) { + for (let row of rows) { response.push( - this.buildRowObject(headerValues, row.toObject(), row._rowNumber) + this.buildRowObject(headerValues, row.toObject(), row.rowNumber) ) } + response = dataFilters.runQuery(response, query.filters || {}) + if (query.sort) { if (Object.keys(query.sort).length !== 1) { console.warn("Googlesheets does not support multiple sorting", {