Skip to content

Commit

Permalink
fix(task): add timestamp now
Browse files Browse the repository at this point in the history
wisley7l committed Sep 9, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 3019c71 commit d5afa13
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions functions/lib/tasks.js
Original file line number Diff line number Diff line change
@@ -204,14 +204,15 @@ const handleWorker = async () => {
const notificationRef = admin.firestore().collection('ecom_notifications')
const queueState = queueController.data()
const queueLastExecution = queueState.last_excution?.toMillis()
const now = admin.firestore.Timestamp.now().toMillis()
if (queueLastExecution) {
console.log(`last ${queueLastExecution} ${queueLastExecution >= 2 * 60 * 1000}`)
console.log(`last ${queueLastExecution} ${now} ${now - queueLastExecution >= 2 * 60 * 1000}`)
}
if (queueState.running && (!queueState.store_ids || !queueState.store_ids.length)) {
return
}
const query = notificationRef
.where('ready_at', '<=', admin.firestore.Timestamp.now().toMillis())
.where('ready_at', '<=', now)
.orderBy('ready_at').limit(100)

const notificationDocs = await query.get()

0 comments on commit d5afa13

Please sign in to comment.