mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 08:14:35 -04:00
Delay events slightly to prevent race conditions
This commit is contained in:
parent
cda41fbd46
commit
c76cb3eb7c
@ -21,6 +21,8 @@ class CreateInvoiceActivity implements ShouldQueue
|
|||||||
{
|
{
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -21,6 +21,8 @@ class InvoiceArchivedActivity implements ShouldQueue
|
|||||||
{
|
{
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -21,6 +21,8 @@ class InvoiceCancelledActivity implements ShouldQueue
|
|||||||
{
|
{
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -24,6 +24,8 @@ class InvoiceCreatedNotification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use UserNotifies;
|
use UserNotifies;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ class InvoiceDeletedActivity implements ShouldQueue
|
|||||||
{
|
{
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -21,6 +21,8 @@ class InvoiceEmailActivity implements ShouldQueue
|
|||||||
{
|
{
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -21,6 +21,8 @@ class InvoiceEmailFailedActivity implements ShouldQueue
|
|||||||
{
|
{
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -24,6 +24,8 @@ class InvoiceEmailedNotification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use UserNotifies;
|
use UserNotifies;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,8 @@ class InvoiceFailedEmailNotification
|
|||||||
{
|
{
|
||||||
use UserNotifies;
|
use UserNotifies;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ class InvoicePaidActivity implements ShouldQueue
|
|||||||
{
|
{
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -20,6 +20,8 @@ class InvoiceReminderEmailActivity implements ShouldQueue
|
|||||||
{
|
{
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -21,6 +21,8 @@ class InvoiceRestoredActivity implements ShouldQueue
|
|||||||
{
|
{
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -21,6 +21,8 @@ class InvoiceReversedActivity implements ShouldQueue
|
|||||||
{
|
{
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -21,6 +21,8 @@ class InvoiceViewedActivity implements ShouldQueue
|
|||||||
{
|
{
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -21,6 +21,8 @@ class UpdateInvoiceActivity implements ShouldQueue
|
|||||||
{
|
{
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -16,6 +16,9 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|||||||
|
|
||||||
class UpdateInvoiceInvitations implements ShouldQueue
|
class UpdateInvoiceInvitations implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -19,6 +19,8 @@ class PaymentEmailFailureActivity implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use UserNotifies;
|
use UserNotifies;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -17,6 +17,8 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|||||||
|
|
||||||
class PaymentEmailedActivity implements ShouldQueue
|
class PaymentEmailedActivity implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
use UserNotifies;
|
use UserNotifies;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,6 +26,9 @@ class PaymentNotification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use UserNotifies;
|
use UserNotifies;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -21,6 +21,8 @@ class PaymentRestoredActivity implements ShouldQueue
|
|||||||
{
|
{
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -21,6 +21,8 @@ class CreateQuoteInvitation implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use MakesHash;
|
use MakesHash;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the event.
|
* Handle the event.
|
||||||
*
|
*
|
||||||
|
@ -21,6 +21,8 @@ class QuoteApprovedActivity implements ShouldQueue
|
|||||||
{
|
{
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the event listener.
|
* Create the event listener.
|
||||||
*
|
*
|
||||||
|
@ -25,6 +25,8 @@ class QuoteApprovedNotification implements ShouldQueue
|
|||||||
{
|
{
|
||||||
use UserNotifies;
|
use UserNotifies;
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,8 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|||||||
|
|
||||||
class QuoteApprovedWebhook implements ShouldQueue
|
class QuoteApprovedWebhook implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ use stdClass;
|
|||||||
|
|
||||||
class QuoteArchivedActivity implements ShouldQueue
|
class QuoteArchivedActivity implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +22,8 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|||||||
|
|
||||||
class QuoteCreatedNotification implements ShouldQueue
|
class QuoteCreatedNotification implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
use UserNotifies;
|
use UserNotifies;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
@ -19,6 +19,8 @@ use stdClass;
|
|||||||
|
|
||||||
class QuoteDeletedActivity implements ShouldQueue
|
class QuoteDeletedActivity implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,8 @@ use stdClass;
|
|||||||
|
|
||||||
class QuoteEmailActivity implements ShouldQueue
|
class QuoteEmailActivity implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +22,9 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|||||||
|
|
||||||
class QuoteEmailedNotification implements ShouldQueue
|
class QuoteEmailedNotification implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
use UserNotifies;
|
use UserNotifies;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
|
@ -19,6 +19,8 @@ use stdClass;
|
|||||||
|
|
||||||
class QuoteRestoredActivity implements ShouldQueue
|
class QuoteRestoredActivity implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,8 @@ use stdClass;
|
|||||||
|
|
||||||
class QuoteViewedActivity implements ShouldQueue
|
class QuoteViewedActivity implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
public $delay = 5;
|
||||||
|
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,9 +91,16 @@ class UpdateInvoicePayment
|
|||||||
->workFlow()
|
->workFlow()
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Remove the event updater from within the loop to prevent race conditions */
|
||||||
|
|
||||||
|
$invoices->each(function ($invoice) {
|
||||||
|
|
||||||
|
event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
$this->payment->saveQuietly();
|
$this->payment->saveQuietly();
|
||||||
|
|
||||||
return $this->payment;
|
return $this->payment;
|
||||||
|
@ -330,17 +330,17 @@ trait MakesInvoiceValues
|
|||||||
// but that's no longer necessary.
|
// but that's no longer necessary.
|
||||||
|
|
||||||
if (isset($item->tax_rate1)) {
|
if (isset($item->tax_rate1)) {
|
||||||
$data[$key][$table_type.'.tax_rate1'] = round($item->tax_rate1, 2).'%';
|
$data[$key][$table_type.'.tax_rate1'] = floatval($item->tax_rate1).'%';
|
||||||
$data[$key][$table_type.'.tax1'] = &$data[$key][$table_type.'.tax_rate1'];
|
$data[$key][$table_type.'.tax1'] = &$data[$key][$table_type.'.tax_rate1'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($item->tax_rate2)) {
|
if (isset($item->tax_rate2)) {
|
||||||
$data[$key][$table_type.'.tax_rate2'] = round($item->tax_rate2, 2).'%';
|
$data[$key][$table_type.'.tax_rate2'] = floatval($item->tax_rate2).'%';
|
||||||
$data[$key][$table_type.'.tax2'] = &$data[$key][$table_type.'.tax_rate2'];
|
$data[$key][$table_type.'.tax2'] = &$data[$key][$table_type.'.tax_rate2'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($item->tax_rate3)) {
|
if (isset($item->tax_rate3)) {
|
||||||
$data[$key][$table_type.'.tax_rate3'] = round($item->tax_rate3, 2).'%';
|
$data[$key][$table_type.'.tax_rate3'] = floatval($item->tax_rate3).'%';
|
||||||
$data[$key][$table_type.'.tax3'] = &$data[$key][$table_type.'.tax_rate3'];
|
$data[$key][$table_type.'.tax3'] = &$data[$key][$table_type.'.tax_rate3'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,12 +38,11 @@ class RedisVsDatabaseTest extends TestCase
|
|||||||
|
|
||||||
$currencies = Cache::get('currencies');
|
$currencies = Cache::get('currencies');
|
||||||
|
|
||||||
$currency = $currencies->filter(function ($item) {
|
$currencies->filter(function ($item) {
|
||||||
return $item->id == 17;
|
return $item->id == 17;
|
||||||
})->first();
|
})->first();
|
||||||
|
|
||||||
|
nlog(microtime(true) - $start);
|
||||||
$total_time = microtime(true) - $start;
|
|
||||||
|
|
||||||
$this->assertTrue(true);
|
$this->assertTrue(true);
|
||||||
// nlog($total_time);
|
// nlog($total_time);
|
||||||
@ -57,8 +56,7 @@ class RedisVsDatabaseTest extends TestCase
|
|||||||
|
|
||||||
$currency = Currency::find(17);
|
$currency = Currency::find(17);
|
||||||
|
|
||||||
$total_time = microtime(true) - $start;
|
nlog(microtime(true) - $start);
|
||||||
|
|
||||||
|
|
||||||
$this->assertTrue(true);
|
$this->assertTrue(true);
|
||||||
// nlog($total_time);
|
// nlog($total_time);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user