adds feature that removes 404 spreadsheets

This commit is contained in:
msramalho
2024-03-12 13:40:46 +00:00
parent 7c4e301d4d
commit 3101db4d24
2 changed files with 13 additions and 2 deletions

View File

@@ -51,7 +51,18 @@ exports.processSheetScheduler = onSchedule(
console.log(`skipping document: ${doc.id} as its hash%60 (${hashToSixty}) does not match the cron minute (${eventDate.getMinutes()})`);
return;
}
logger.log(`processing document ${doc.id}, its hash % 60 (${hashToSixty}) matches the cron minute (${eventDate.getMinutes()})`);
logger.log(`processing document ${doc.id}, its hash % 60 (${hashToSixty}) matches the cron minute (${eventDate.getMinutes()})`);
// try to access the spreadsheet and delete the document if it's not found, users will delete/change auth on sheets and we don't want to keep processing them
try {
s3 = await gapi.client.sheets.spreadsheets.get({spreadsheetId: doc.id,});
} catch (e) {
logger.log(e);
if (e.status == 404) {
await doc.ref.delete();
logger.log(`document ${doc.id} not found, deleted`);
}
}
// send POST request with sheetID to trigger sheet processing
const url = "https://auto-archiver-api.bellingcat.com/sheet_service";

View File

@@ -342,7 +342,7 @@ export default new Vuex.Store({
);
const response = await getDocs(q);
if(response.docs.length > 0) {
if (response.docs.length > 0) {
throw "Sheet already enabled";
}