Save last_subscriber_id as we go

Otherwise the task would always be starting at 0 if it times out

MAILPOET-5404
This commit is contained in:
John Oleksowicz
2023-07-11 15:51:53 -05:00
committed by Veljko V
parent b02ef8fe8f
commit 2078ddf292

View File

@ -32,18 +32,16 @@ class BackfillEngagementData extends SimpleWorker {
$this->cronHelper->enforceExecutionLimit($timer);
$batch = $this->engagementDataBackfiller->getBatch($lastSubscriberId);
if (empty($batch)) {
$this->engagementDataBackfiller->setLastProcessedSubscriberId($lastSubscriberId);
break;
}
$this->engagementDataBackfiller->updateBatch($batch);
$lastSubscriberId = $this->engagementDataBackfiller->getLastProcessedSubscriberId();
$meta['last_subscriber_id'] = $lastSubscriberId;
$task->setMeta($meta);
$this->scheduledTasksRepository->persist($task);
$this->scheduledTasksRepository->flush();
} while (count($batch) === self::BATCH_SIZE);
$meta['last_subscriber_id'] = $this->engagementDataBackfiller->getLastProcessedSubscriberId();
$task->setMeta($meta);
$this->scheduledTasksRepository->persist($task);
$this->scheduledTasksRepository->flush();
return true;
}
}