Skip to content

Commit

Permalink
fix(handle-events): update debug
Browse files Browse the repository at this point in the history
  • Loading branch information
wisley7l committed Sep 19, 2024
1 parent e0ffb27 commit 481ad77
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions functions/lib/events/handle-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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,
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit 481ad77

Please sign in to comment.