From 481ad7767f18c33656dca7f31ba72efb56e22b1d Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Thu, 19 Sep 2024 16:11:27 -0300 Subject: [PATCH] fix(handle-events): update debug --- functions/lib/events/handle-queue.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/lib/events/handle-queue.js b/functions/lib/events/handle-queue.js index f445dfe..2337f73 100644 --- a/functions/lib/events/handle-queue.js +++ b/functions/lib/events/handle-queue.js @@ -17,6 +17,7 @@ const createEvent = async (storeId, id, documentId) => { if (docEventSnapshot.exists) { const { createdAt } = docEventSnapshot.data() if ((Timestamp.now() - new Date(createdAt).getTime()) > limitTimeProcessing) { + logger.info('1') await docEvent.delete() return admin.firestore().doc(`${documentId}`) .update({ @@ -25,9 +26,11 @@ const createEvent = async (storeId, id, documentId) => { }) .then(() => null) } + logger.info('2') return null } + logger.info('3') return docEvent.set({ documentId, storeId, @@ -62,11 +65,9 @@ const addEventsQueue = async (event) => { const processingTime = processingAt && (now.toMillis() - processingAt.toMillis()) const isProcessing = processingTime && processingTime < limitTimeProcessing if (!storeId || attempts > 3) { - logger.info('0') await deleteEvent(storeId, id) // event starts only on creation await docOldestEvent.ref.delete() } else if (!processingAt) { - logger.info('1') await createEvent(storeId, id, documentId) .then(async (resp) => { if (resp) { @@ -90,7 +91,6 @@ const addEventsQueue = async (event) => { lastExecuted: documentId }, { merge: true }) } else if (!isProcessing) { - logger.info('2') await deleteEvent(storeId, id) // event starts only on creation const attempts = (oldestEvent.attempts || 0) + 1