Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
haitv282 committed Dec 6, 2022
1 parent 66d5e83 commit e09d2be
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Cron/ClearLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ public function execute()
$logs = $this->collectionLog->create()
->addFieldToFilter('created_at', ['lteq' => date('Y-m-d H:i:s', $timeEnd)]);

$logs->setPageSize(50);
/**
* We've stumbled into a case where the module would run out of memory if the emails sent were too many like (400k) in our case. By the time the cleanup cron tried to clean them, it would run out of memory.
* I've used collection pagination to reduce the strain of this cleanup cron job. #394
*/
$logs->setPageSize(100);
$pages = $logs->getLastPageNumber();
for ($pageNum = 1; $pageNum<=$pages; $pageNum++) {
$logs->setCurPage($pageNum);
Expand Down

0 comments on commit e09d2be

Please sign in to comment.