mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-04 07:24:37 -04:00
Analytics on queue size
This commit is contained in:
parent
aeae0a19ab
commit
6a99cba813
@ -18,6 +18,7 @@ use App\Jobs\Cron\SubscriptionCron;
|
|||||||
use App\Jobs\Ledger\LedgerBalanceUpdate;
|
use App\Jobs\Ledger\LedgerBalanceUpdate;
|
||||||
use App\Jobs\Ninja\AdjustEmailQuota;
|
use App\Jobs\Ninja\AdjustEmailQuota;
|
||||||
use App\Jobs\Ninja\CompanySizeCheck;
|
use App\Jobs\Ninja\CompanySizeCheck;
|
||||||
|
use App\Jobs\Ninja\QueueSize;
|
||||||
use App\Jobs\Util\DiskCleanup;
|
use App\Jobs\Util\DiskCleanup;
|
||||||
use App\Jobs\Util\ReminderJob;
|
use App\Jobs\Util\ReminderJob;
|
||||||
use App\Jobs\Util\SchedulerCheck;
|
use App\Jobs\Util\SchedulerCheck;
|
||||||
@ -56,6 +57,7 @@ class Kernel extends ConsoleKernel
|
|||||||
$schedule->job(new ReminderJob)->hourly()->withoutOverlapping();
|
$schedule->job(new ReminderJob)->hourly()->withoutOverlapping();
|
||||||
|
|
||||||
// $schedule->job(new LedgerBalanceUpdate)->everyFiveMinutes()->withoutOverlapping();
|
// $schedule->job(new LedgerBalanceUpdate)->everyFiveMinutes()->withoutOverlapping();
|
||||||
|
$schedule->job(new QueueSize)->everyFiveMinutes()->withoutOverlapping();
|
||||||
|
|
||||||
$schedule->job(new CompanySizeCheck)->daily()->withoutOverlapping();
|
$schedule->job(new CompanySizeCheck)->daily()->withoutOverlapping();
|
||||||
|
|
||||||
|
79
app/DataMapper/Analytics/QueueSize.php
Normal file
79
app/DataMapper/Analytics/QueueSize.php
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\DataMapper\Analytics;
|
||||||
|
|
||||||
|
use Turbo124\Beacon\ExampleMetric\GenericMixedMetric;
|
||||||
|
|
||||||
|
class QueueSize extends GenericMixedMetric
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of Sample.
|
||||||
|
*
|
||||||
|
* Monotonically incrementing counter
|
||||||
|
*
|
||||||
|
* - counter
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $type = 'mixed_metric';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the counter.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $name = 'ninja.queue_size';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The datetime of the counter measurement.
|
||||||
|
*
|
||||||
|
* date("Y-m-d H:i:s")
|
||||||
|
*
|
||||||
|
* @var DateTime
|
||||||
|
*/
|
||||||
|
public $datetime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class failure name
|
||||||
|
* set to 0.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $string_metric5 = 'stub';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The exception string
|
||||||
|
* set to 0.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $string_metric6 = 'stub';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The counter
|
||||||
|
* set to 1.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $int_metric1 = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Company Key
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $string_metric7 = '';
|
||||||
|
|
||||||
|
public function __construct($int_metric1) {
|
||||||
|
$this->int_metric1 = $int_metric1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
48
app/Jobs/Ninja/QueueSize.php
Normal file
48
app/Jobs/Ninja/QueueSize.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Jobs\Ninja;
|
||||||
|
|
||||||
|
use App\DataMapper\Analytics\QueueSize as QueueSizeAnalytic;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Facades\Queue;
|
||||||
|
use Turbo124\Beacon\Facades\LightLogs;
|
||||||
|
use Turbo124\Beacon\Jobs\Database\MySQL\DbStatus;
|
||||||
|
|
||||||
|
class QueueSize implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
LightLogs::create(new QueueSizeAnalytic(Queue::size()))
|
||||||
|
->queue();
|
||||||
|
}
|
||||||
|
}
|
@ -153,10 +153,12 @@ class InvoiceEmailEngine extends BaseEmailEngine
|
|||||||
|
|
||||||
$line_items = $this->invoice->line_items;
|
$line_items = $this->invoice->line_items;
|
||||||
|
|
||||||
$expense_ids = [];
|
|
||||||
|
|
||||||
foreach($line_items as $item)
|
foreach($line_items as $item)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$expense_ids = [];
|
||||||
|
|
||||||
if(property_exists($item, 'expense_id'))
|
if(property_exists($item, 'expense_id'))
|
||||||
{
|
{
|
||||||
$expense_ids[] = $item->expense_id;
|
$expense_ids[] = $item->expense_id;
|
||||||
@ -178,7 +180,7 @@ class InvoiceEmailEngine extends BaseEmailEngine
|
|||||||
}
|
}
|
||||||
|
|
||||||
$task_ids = [];
|
$task_ids = [];
|
||||||
|
|
||||||
if(property_exists($item, 'task_id'))
|
if(property_exists($item, 'task_id'))
|
||||||
{
|
{
|
||||||
$task_ids[] = $item->task_id;
|
$task_ids[] = $item->task_id;
|
||||||
|
@ -45,8 +45,8 @@ class SendEmail
|
|||||||
|
|
||||||
$this->credit->invitations->each(function ($invitation) {
|
$this->credit->invitations->each(function ($invitation) {
|
||||||
if (!$invitation->contact->trashed() && $invitation->contact->email) {
|
if (!$invitation->contact->trashed() && $invitation->contact->email) {
|
||||||
$email_builder = (new CreditEmail())->build($invitation, $this->reminder_template);
|
|
||||||
|
// $email_builder = (new CreditEmail())->build($invitation, $this->reminder_template);
|
||||||
// EmailCredit::dispatchNow($email_builder, $invitation, $invitation->company);
|
// EmailCredit::dispatchNow($email_builder, $invitation, $invitation->company);
|
||||||
EmailEntity::dispatchNow($invitation, $invitation->company, $this->reminder_template);
|
EmailEntity::dispatchNow($invitation, $invitation->company, $this->reminder_template);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user