1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Capture sending metrics

This commit is contained in:
David Bomba 2022-08-09 07:26:43 +10:00
parent 820070925a
commit 962ea9cc69
2 changed files with 8 additions and 4 deletions

View File

@ -40,7 +40,8 @@ class RecurringInvoicesCron
public function handle() : void
{
/* Get all invoices where the send date is less than NOW + 30 minutes() */
nlog('Sending recurring invoices '.Carbon::now()->format('Y-m-d h:i:s'));
$start = Carbon::now()->format('Y-m-d h:i:s');
nlog('Sending recurring invoices '.$start);
if (! config('ninja.db.multi_db_enabled')) {
$recurring_invoices = RecurringInvoice::where('next_send_date', '<=', now()->toDateTimeString())
@ -119,5 +120,8 @@ class RecurringInvoicesCron
});
}
}
nlog("Recurring invoice send duration " . $start . " - " . Carbon::now()->format('Y-m-d h:i:s'));
}
}

View File

@ -127,7 +127,7 @@ class SendRecurring implements ShouldQueue
$invoice->invitations->each(function ($invitation) use ($invoice) {
if ($invitation->contact && ! $invitation->contact->trashed() && strlen($invitation->contact->email) >= 1 && $invoice->client->getSetting('auto_email_invoice')) {
try {
EmailEntity::dispatch($invitation, $invoice->company)->delay(10);
EmailEntity::dispatch($invitation, $invoice->company)->delay(rand(10,20));
} catch (\Exception $e) {
nlog($e->getMessage());
}
@ -140,13 +140,13 @@ class SendRecurring implements ShouldQueue
if ($invoice->client->getSetting('auto_bill_date') == 'on_send_date' && $invoice->auto_bill_enabled) {
nlog("attempting to autobill {$invoice->number}");
// $invoice->service()->autoBill();
AutoBill::dispatch($invoice, $this->db)->delay(20);
AutoBill::dispatch($invoice, $this->db)->delay(rand(30,40));
} elseif ($invoice->client->getSetting('auto_bill_date') == 'on_due_date' && $invoice->auto_bill_enabled) {
if ($invoice->due_date && Carbon::parse($invoice->due_date)->startOfDay()->lte(now()->startOfDay())) {
nlog("attempting to autobill {$invoice->number}");
// $invoice->service()->autoBill();
AutoBill::dispatch($invoice, $this->db)->delay(20);
AutoBill::dispatch($invoice, $this->db)->delay(rand(30,40));
}
}
}