Refactor code structure for improved readability and maintainability
Build Images and Deploy / Update-PROD-Stack (push) Successful in 1m19s

This commit is contained in:
2026-03-18 21:42:07 -04:00
parent 3b40f0f869
commit 1ab8763089
2 changed files with 8 additions and 7 deletions
+7 -6
View File
@@ -209,19 +209,20 @@ const schedulerWorker = new Worker(
return
}
// Remove any already-waiting jobs to avoid duplicates
const waiting = await priceUpdateQueue.getJobs(['waiting', 'delayed'])
const waitingIds = new Set(waiting.map((j) => j.data?.hashtagId))
// Skip hashtags already in-flight (waiting or active) to avoid pile-up
const inFlight = await priceUpdateQueue.getJobs(['waiting', 'active', 'delayed'])
const inFlightIds = new Set(inFlight.map((j) => j.data?.hashtagId))
const toQueue = hashtags.filter((h) => !waitingIds.has(h.id))
const toQueue = hashtags.filter((h) => !inFlightIds.has(h.id))
for (const hashtag of toQueue) {
await priceUpdateQueue.add(
'update-price',
{ hashtagId: hashtag.id, tag: hashtag.tag },
{
jobId: `price-${hashtag.id}`, // deduplicates against waiting/active (hash persists)
removeOnComplete: true, // remove hash on completion so jobId can be reused next sweep
// No static jobId — avoids silent dedup drops from stale Redis hashes.
// In-flight dedup is handled by the inFlightIds check above.
removeOnComplete: true,
removeOnFail: { count: 50 },
attempts: 3,
backoff: { type: 'exponential', delay: 5000 },
+1 -1
View File
File diff suppressed because one or more lines are too long