Merge pull request #7991 from turbo124/v5-develop

Refactor reminder crons
This commit is contained in:
David Bomba 2022-11-27 16:26:21 +11:00 committed by GitHub
commit aeda0af082
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,9 +46,11 @@ class ReminderJob implements ShouldQueue
*/ */
public function handle() :void public function handle() :void
{ {
set_time_limit(0);
if (! config('ninja.db.multi_db_enabled')) if (! config('ninja.db.multi_db_enabled'))
{ {
set_time_limit(0);
nlog("Sending invoice reminders on ".now()->format('Y-m-d h:i:s')); nlog("Sending invoice reminders on ".now()->format('Y-m-d h:i:s'));
@ -65,10 +67,15 @@ class ReminderJob implements ShouldQueue
->whereHas('company', function ($query) { ->whereHas('company', function ($query) {
$query->where('is_disabled', 0); $query->where('is_disabled', 0);
}) })
->with('invitations')->cursor()->each(function ($invoice) { ->with('invitations')->chunk(50, function ($invoices) {
$this->sendReminderForInvoice($invoice); foreach($invoices as $invoice)
{
$this->sendReminderForInvoice($invoice);
}
sleep(2);
}); });
@ -95,11 +102,16 @@ class ReminderJob implements ShouldQueue
->whereHas('company', function ($query) { ->whereHas('company', function ($query) {
$query->where('is_disabled', 0); $query->where('is_disabled', 0);
}) })
->with('invitations')->cursor()->each(function ($invoice) { ->with('invitations')->chunk(50, function ($invoices) {
// if ($invoice->refresh() && $invoice->isPayable()) { // if ($invoice->refresh() && $invoice->isPayable()) {
foreach($invoices as $invoice)
{
$this->sendReminderForInvoice($invoice); $this->sendReminderForInvoice($invoice);
}
sleep(2);
}); });
} }