Adjust delays for observers

This commit is contained in:
David Bomba 2022-05-15 20:14:14 +10:00
parent 7c3613455d
commit aeae0a19ab
13 changed files with 32 additions and 25 deletions

View File

@ -55,7 +55,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 CompanySizeCheck)->daily()->withoutOverlapping(); $schedule->job(new CompanySizeCheck)->daily()->withoutOverlapping();

View File

@ -104,7 +104,7 @@ class StorePaymentRequest extends Request
'credits.*.credit_id' => new ValidCreditsRules($this->all()), 'credits.*.credit_id' => new ValidCreditsRules($this->all()),
'credits.*.amount' => ['required', new CreditsSumRule($this->all())], 'credits.*.amount' => ['required', new CreditsSumRule($this->all())],
'invoices' => new ValidPayableInvoicesRule(), 'invoices' => new ValidPayableInvoicesRule(),
'number' => ['nullable', Rule::unique('payments')->where('company_id', auth()->user()->company()->id)], 'number' => ['nullable', 'bail', Rule::unique('payments')->where('company_id', auth()->user()->company()->id)],
]; ];

View File

@ -177,6 +177,8 @@ class InvoiceEmailEngine extends BaseEmailEngine
}); });
} }
$task_ids = [];
if(property_exists($item, 'task_id')) if(property_exists($item, 'task_id'))
{ {
$task_ids[] = $item->task_id; $task_ids[] = $item->task_id;

View File

@ -48,4 +48,9 @@ class CompanyLedger extends Model
{ {
return $this->morphTo(); return $this->morphTo();
} }
public function client()
{
return $this->belongsTo(Client::class);
}
} }

View File

@ -30,7 +30,7 @@ class ClientObserver
->exists(); ->exists();
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_CREATE_CLIENT, $client, $client->company); WebhookHandler::dispatch(Webhook::EVENT_CREATE_CLIENT, $client, $client->company)->delay(now()->addSeconds(2));
} }
} }
@ -47,7 +47,7 @@ class ClientObserver
->exists(); ->exists();
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_UPDATE_CLIENT, $client, $client->company); WebhookHandler::dispatch(Webhook::EVENT_UPDATE_CLIENT, $client, $client->company)->delay(now()->addSeconds(2));
} }
} }
@ -64,7 +64,7 @@ class ClientObserver
->exists(); ->exists();
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_DELETE_CLIENT, $client, $client->company); WebhookHandler::dispatch(Webhook::EVENT_DELETE_CLIENT, $client, $client->company)->delay(now()->addSeconds(2));
} }
} }

View File

@ -30,7 +30,7 @@ class ExpenseObserver
->exists(); ->exists();
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_CREATE_EXPENSE, $expense, $expense->company); WebhookHandler::dispatch(Webhook::EVENT_CREATE_EXPENSE, $expense, $expense->company)->delay(now()->addSeconds(2));
} }
} }
@ -47,7 +47,7 @@ class ExpenseObserver
->exists(); ->exists();
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_UPDATE_EXPENSE, $expense, $expense->company); WebhookHandler::dispatch(Webhook::EVENT_UPDATE_EXPENSE, $expense, $expense->company)->delay(now()->addSeconds(2));
} }
} }
@ -64,7 +64,7 @@ class ExpenseObserver
->exists(); ->exists();
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_DELETE_EXPENSE, $expense, $expense->company); WebhookHandler::dispatch(Webhook::EVENT_DELETE_EXPENSE, $expense, $expense->company)->delay(now()->addSeconds(2));
} }
} }

View File

@ -36,7 +36,7 @@ class InvoiceObserver
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_CREATE_INVOICE, $invoice, $invoice->company, 'client'); WebhookHandler::dispatch(Webhook::EVENT_CREATE_INVOICE, $invoice, $invoice->company, 'client')->delay(now()->addSeconds(2));
} }
} }
@ -55,7 +55,7 @@ class InvoiceObserver
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_UPDATE_INVOICE, $invoice, $invoice->company, 'client'); WebhookHandler::dispatch(Webhook::EVENT_UPDATE_INVOICE, $invoice, $invoice->company, 'client')->delay(now()->addSeconds(2));
} }
@ -75,7 +75,7 @@ class InvoiceObserver
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_DELETE_INVOICE, $invoice, $invoice->company, 'client'); WebhookHandler::dispatch(Webhook::EVENT_DELETE_INVOICE, $invoice, $invoice->company, 'client')->delay(now()->addSeconds(2));
} }
} }

View File

@ -30,7 +30,7 @@ class PaymentObserver
->exists(); ->exists();
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_CREATE_PAYMENT, $payment, $payment->company, 'invoices,client')->delay(5); WebhookHandler::dispatch(Webhook::EVENT_CREATE_PAYMENT, $payment, $payment->company, 'invoices,client')->delay(now()->addSeconds(20));
} }
} }
@ -57,7 +57,7 @@ class PaymentObserver
->exists(); ->exists();
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_DELETE_PAYMENT, $payment, $payment->company, 'invoices,client')->delay(5); WebhookHandler::dispatch(Webhook::EVENT_DELETE_PAYMENT, $payment, $payment->company, 'invoices,client')->delay(now()->addSeconds(20));
} }
} }

View File

@ -32,7 +32,7 @@ class ProjectObserver
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_PROJECT_CREATE, $project, $project->company, 'client'); WebhookHandler::dispatch(Webhook::EVENT_PROJECT_CREATE, $project, $project->company, 'client')->delay(now()->addSeconds(2));
} }
} }
@ -50,7 +50,7 @@ class ProjectObserver
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_PROJECT_UPDATE, $project, $project->company, 'client'); WebhookHandler::dispatch(Webhook::EVENT_PROJECT_UPDATE, $project, $project->company, 'client')->delay(now()->addSeconds(2));
} }
} }

View File

@ -33,7 +33,7 @@ class QuoteObserver
if ($subscriptions) { if ($subscriptions) {
$quote->load('client'); $quote->load('client');
WebhookHandler::dispatch(Webhook::EVENT_CREATE_QUOTE, $quote, $quote->company, 'client'); WebhookHandler::dispatch(Webhook::EVENT_CREATE_QUOTE, $quote, $quote->company, 'client')->delay(now()->addSeconds(2));
} }
} }
@ -53,7 +53,7 @@ class QuoteObserver
if ($subscriptions) { if ($subscriptions) {
$quote->load('client'); $quote->load('client');
WebhookHandler::dispatch(Webhook::EVENT_UPDATE_QUOTE, $quote, $quote->company, 'client'); WebhookHandler::dispatch(Webhook::EVENT_UPDATE_QUOTE, $quote, $quote->company, 'client')->delay(now()->addSeconds(2));
} }
} }
@ -72,7 +72,7 @@ class QuoteObserver
if ($subscriptions) { if ($subscriptions) {
$quote->load('client'); $quote->load('client');
WebhookHandler::dispatch(Webhook::EVENT_DELETE_QUOTE, $quote, $quote->company, 'client'); WebhookHandler::dispatch(Webhook::EVENT_DELETE_QUOTE, $quote, $quote->company, 'client')->delay(now()->addSeconds(2));
} }
} }

View File

@ -30,7 +30,7 @@ class TaskObserver
->exists(); ->exists();
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_CREATE_TASK, $task, $task->company); WebhookHandler::dispatch(Webhook::EVENT_CREATE_TASK, $task, $task->company)->delay(now()->addSeconds(2));
} }
} }
@ -47,7 +47,7 @@ class TaskObserver
->exists(); ->exists();
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_UPDATE_TASK, $task, $task->company); WebhookHandler::dispatch(Webhook::EVENT_UPDATE_TASK, $task, $task->company)->delay(now()->addSeconds(2));
} }
} }
@ -64,7 +64,7 @@ class TaskObserver
->exists(); ->exists();
if ($subscriptions) { if ($subscriptions) {
WebhookHandler::dispatch(Webhook::EVENT_DELETE_TASK, $task, $task->company); WebhookHandler::dispatch(Webhook::EVENT_DELETE_TASK, $task, $task->company)->delay(now()->addSeconds(2));
} }
} }

View File

@ -568,7 +568,7 @@ class StripePaymentDriver extends BaseDriver
//payment_intent.succeeded - this will confirm or cancel the payment //payment_intent.succeeded - this will confirm or cancel the payment
if($request->type === 'payment_intent.succeeded'){ if($request->type === 'payment_intent.succeeded'){
PaymentIntentWebhook::dispatch($request->data, $request->company_key, $this->company_gateway->id)->delay(10); PaymentIntentWebhook::dispatch($request->data, $request->company_key, $this->company_gateway->id)->delay(now()->addSeconds(10));
return response()->json([], 200); return response()->json([], 200);
} }

View File

@ -37,7 +37,7 @@ class LedgerService
$this->entity->company_ledger()->save($company_ledger); $this->entity->company_ledger()->save($company_ledger);
ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client)->delay(300); ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client)->delay(now()->addSeconds(300));
return $this; return $this;
} }
@ -54,7 +54,7 @@ class LedgerService
$this->entity->company_ledger()->save($company_ledger); $this->entity->company_ledger()->save($company_ledger);
ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client)->delay(300); ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client)->delay(now()->addSeconds(300));
return $this; return $this;
} }
@ -71,7 +71,7 @@ class LedgerService
$this->entity->company_ledger()->save($company_ledger); $this->entity->company_ledger()->save($company_ledger);
ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client)->delay(300); ClientLedgerBalanceUpdate::dispatch($this->entity->company, $this->entity->client)->delay(now()->addSeconds(300));
return $this; return $this;
} }