Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filtering of deleted synced sheets #4210

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions connectors/src/connectors/google_drive/temporal/spreadsheets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ export async function syncSpreadSheet(
// List synced sheets.
const syncedSheets = await GoogleDriveSheet.findAll({
where: {
connectorId: connector.id,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚗

driveFileId: file.id,
},
});
Expand All @@ -451,9 +452,11 @@ export async function syncSpreadSheet(
// or have exceeded the maximum number of rows.
const deletedSyncedSheets = syncedSheets.filter(
(synced) =>
!successfulSheetIdImports.find(
// Check for undefined explicitly, avoiding incorrect filtering
// due to falsy values (0 can be a valid sheet ID).
successfulSheetIdImports.find(
(sheetId) => sheetId === synced.driveSheetId
)
) === undefined
);
if (deletedSyncedSheets.length > 0) {
await deleteAllSheets(connector, deletedSyncedSheets, {
Expand All @@ -475,7 +478,9 @@ async function deleteSheetForSpreadsheet(
{
connectorId: connector.id,
sheet,
spreadsheetFileId,
spreadsheet: {
id: spreadsheetFileId,
},
},
"[Spreadsheet] Deleting google drive sheet."
);
Expand Down
Loading