Prevents campaign loading progress clobbering (#644)

This commit is contained in:
Chris Anderson 2025-03-08 17:49:47 -06:00 committed by GitHub
parent d728ed2523
commit 0afe09da05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,10 +25,6 @@ export default class CampaignGenerateListJob extends Job {
// Approximate the size of the send list
const estimatedSize = await estimatedSendSize(campaign)
// Use approximate size for progress
await cacheSet<number>(App.main.redis, CacheKeys.populationTotal(campaign), estimatedSize, 86400)
await cacheSet<number>(App.main.redis, CacheKeys.populationProgress(campaign), 0, 86400)
// Increase lock duration based on estimated send size
const lockTime = Math.ceil(Math.max(estimatedSize / 1000, 900))
logger.info({ id, estimatedSize, lockTime }, 'campaign:generate:estimated_size')
@ -37,6 +33,10 @@ export default class CampaignGenerateListJob extends Job {
logger.info({ id, acquired }, 'campaign:generate:lock')
if (!acquired) return
// Use approximate size for progress
await cacheSet<number>(App.main.redis, CacheKeys.populationTotal(campaign), estimatedSize, 86400)
await cacheSet<number>(App.main.redis, CacheKeys.populationProgress(campaign), 0, 86400)
logger.info({ id }, 'campaign:generate:querying')
await generateSendList(campaign)