Fix to accommodate filtering updates for GoogleSheets

This commit is contained in:
Dean 2024-09-09 16:10:39 +01:00
parent 0f8df77ded
commit ee968b212a
1 changed files with 6 additions and 10 deletions

View File

@ -566,24 +566,20 @@ class GoogleSheetsIntegration implements DatasourcePlus {
query.filters.equal[`_${GOOGLE_SHEETS_PRIMARY_KEY}`] = id 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) { if (hasFilters && query.paginate) {
filtered = filtered.slice(offset, offset + limit) rows = rows.slice(offset, offset + limit)
} }
const headerValues = sheet.headerValues const headerValues = sheet.headerValues
let response = [] let response = []
for (let row of filtered) { for (let row of rows) {
response.push( 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 (query.sort) {
if (Object.keys(query.sort).length !== 1) { if (Object.keys(query.sort).length !== 1) {
console.warn("Googlesheets does not support multiple sorting", { console.warn("Googlesheets does not support multiple sorting", {