Remove DispatchNow()

This commit is contained in:
David Bomba 2022-09-07 14:15:27 +10:00
parent 28915d82a4
commit 52d5afbce0
16 changed files with 20 additions and 28 deletions

View File

@ -189,7 +189,7 @@ class CreateSingleAccount extends Command
$this->createClient($company, $user); $this->createClient($company, $user);
} }
CreateCompanyTaskStatuses::dispatchNow($company, $user); (new CreateCompanyTaskStatuses($company, $user))->handle();
for ($x = 0; $x < $this->count; $x++) { for ($x = 0; $x < $this->count; $x++) {
$client = $company->clients->random(); $client = $company->clients->random();

View File

@ -97,10 +97,6 @@ class SendRemindersCron extends Command
} }
}); });
// SendReminders::dispatchNow();
// $this->webHookOverdueInvoices();
// $this->webHookExpiredQuotes();
} }
private function calcLateFee($invoice, $template) :Invoice private function calcLateFee($invoice, $template) :Invoice

View File

@ -173,7 +173,7 @@ class PreviewPurchaseOrderController extends BaseController
} }
//else //else
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company()); $file_path = (new PreviewPdf($maker->getCompiledHTML(true), auth()->user()->company()))->handle();
return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true); return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
} }
@ -285,7 +285,7 @@ class PreviewPurchaseOrderController extends BaseController
return $pdf; return $pdf;
} }
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), $company); $file_path = (new PreviewPdf($maker->getCompiledHTML(true), $company))->handle();
if(Ninja::isHosted()) if(Ninja::isHosted())
@ -363,7 +363,7 @@ class PreviewPurchaseOrderController extends BaseController
return $pdf; return $pdf;
} }
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company()); $file_path = (new PreviewPdf($maker->getCompiledHTML(true), auth()->user()->company()))->handle();
$response = Response::make($file_path, 200); $response = Response::make($file_path, 200);
$response->header('Content-Type', 'application/pdf'); $response->header('Content-Type', 'application/pdf');
@ -460,7 +460,7 @@ class PreviewPurchaseOrderController extends BaseController
return $pdf; return $pdf;
} }
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company()); $file_path = (new PreviewPdf($maker->getCompiledHTML(true), auth()->user()->company()))->handle();
$response = Response::make($file_path, 200); $response = Response::make($file_path, 200);
$response->header('Content-Type', 'application/pdf'); $response->header('Content-Type', 'application/pdf');

View File

@ -210,7 +210,7 @@ class UserController extends BaseController
$user_agent = request()->input('token_name') ?: request()->server('HTTP_USER_AGENT'); $user_agent = request()->input('token_name') ?: request()->server('HTTP_USER_AGENT');
$ct = CreateCompanyToken::dispatchNow($company, $user, $user_agent); $ct = (new CreateCompanyToken($company, $user, $user_agent))->handle();
event(new UserWasCreated($user, auth()->user(), $company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); event(new UserWasCreated($user, auth()->user(), $company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));

View File

@ -108,8 +108,6 @@ class InvitationController extends Controller
$file_name = $invitation->purchase_order->numberFormatter().'.pdf'; $file_name = $invitation->purchase_order->numberFormatter().'.pdf';
// $file = CreateRawPdf::dispatchNow($invitation, $invitation->company->db);
$file = (new CreatePurchaseOrderPdf($invitation))->rawPdf(); $file = (new CreatePurchaseOrderPdf($invitation))->rawPdf();
$headers = ['Content-Type' => 'application/pdf']; $headers = ['Content-Type' => 'application/pdf'];

View File

@ -507,7 +507,7 @@ class BillingPortalPurchase extends Component
$mailer->settings = $this->subscription->company->settings; $mailer->settings = $this->subscription->company->settings;
$mailer->to_user = $contact; $mailer->to_user = $contact;
NinjaMailerJob::dispatchNow($mailer); NinjaMailerJob::dispatch($mailer);
$this->steps['passwordless_login_sent'] = true; $this->steps['passwordless_login_sent'] = true;
$this->passwordless_login_btn = false; $this->passwordless_login_btn = false;

View File

@ -288,7 +288,7 @@ class CompanyImport implements ShouldQueue
$nmo->company = $_company; $nmo->company = $_company;
$nmo->settings = $_company->settings; $nmo->settings = $_company->settings;
$nmo->to_user = $_company->owner(); $nmo->to_user = $_company->owner();
NinjaMailerJob::dispatchNow($nmo); NinjaMailerJob::dispatch($nmo);
} }
catch(\Exception $e){ catch(\Exception $e){
@ -1644,7 +1644,7 @@ class CompanyImport implements ShouldQueue
$nmo->company = $this->company; $nmo->company = $this->company;
$nmo->settings = $this->company->settings; $nmo->settings = $this->company->settings;
$nmo->to_user = $this->company->owner(); $nmo->to_user = $this->company->owner();
NinjaMailerJob::dispatchNow($nmo); NinjaMailerJob::dispatch($nmo);
} }
} }

View File

@ -52,8 +52,6 @@ class CheckCompanyData implements ShouldQueue
/** /**
* Execute the job. * Execute the job.
*
* @return void
*/ */
public function handle() public function handle()
{ {

View File

@ -252,7 +252,7 @@ class Import implements ShouldQueue
$this->setInitialCompanyLedgerBalances(); $this->setInitialCompanyLedgerBalances();
// $this->fixClientBalances(); // $this->fixClientBalances();
$check_data = CheckCompanyData::dispatchNow($this->company, md5(time())); $check_data = (new CheckCompanyData($this->company, md5(time())))->handle();
// if(Ninja::isHosted() && array_key_exists('ninja_tokens', $data)) // if(Ninja::isHosted() && array_key_exists('ninja_tokens', $data))
$this->processNinjaTokens($data['ninja_tokens']); $this->processNinjaTokens($data['ninja_tokens']);
@ -591,7 +591,7 @@ class Import implements ShouldQueue
$user_agent = array_key_exists('token_name', $resource) ?: request()->server('HTTP_USER_AGENT'); $user_agent = array_key_exists('token_name', $resource) ?: request()->server('HTTP_USER_AGENT');
CreateCompanyToken::dispatchNow($this->company, $user, $user_agent); (new CreateCompanyToken($this->company, $user, $user_agent))->handle();
$key = "users_{$resource['id']}"; $key = "users_{$resource['id']}";
@ -1899,7 +1899,7 @@ class Import implements ShouldQueue
if(Ninja::isHosted()){ if(Ninja::isHosted()){
try{ try{
\Modules\Admin\Jobs\Account\NinjaUser::dispatchNow($data, $this->company); \Modules\Admin\Jobs\Account\NinjaUser::dispatch($data, $this->company);
} }
catch(\Exception $e){ catch(\Exception $e){
nlog($e->getMessage()); nlog($e->getMessage());

View File

@ -212,14 +212,14 @@ class PurchaseOrder extends BaseModel
return Storage::disk(config('filesystems.default'))->{$type}($file_path); return Storage::disk(config('filesystems.default'))->{$type}($file_path);
} }
elseif(Ninja::isHosted() && $portal){ elseif(Ninja::isHosted() && $portal){
$file_path = CreatePurchaseOrderPdf::dispatchNow($invitation,config('filesystems.default')); $file_path = (new CreatePurchaseOrderPdf($invitation,config('filesystems.default')))->handle();
return Storage::disk(config('filesystems.default'))->{$type}($file_path); return Storage::disk(config('filesystems.default'))->{$type}($file_path);
} }
if(Storage::disk('public')->exists($file_path)) if(Storage::disk('public')->exists($file_path))
return Storage::disk('public')->{$type}($file_path); return Storage::disk('public')->{$type}($file_path);
$file_path = CreatePurchaseOrderPdf::dispatchNow($invitation); $file_path = (new CreatePurchaseOrderPdf($invitation))->handle();
return Storage::disk('public')->{$type}($file_path); return Storage::disk('public')->{$type}($file_path);
} }

View File

@ -59,7 +59,7 @@ class ApplyNumber extends AbstractService
} catch (QueryException $e) { } catch (QueryException $e) {
$x++; $x++;
if ($x > 10) { if ($x > 50) {
$this->completed = false; $this->completed = false;
} }
} }

View File

@ -77,7 +77,7 @@ class ApplyNumber extends AbstractService
$x++; $x++;
if($x>10) if($x>50)
$this->completed = false; $this->completed = false;
} }

View File

@ -56,7 +56,7 @@ class ApplyNumber extends AbstractService
} catch (QueryException $e) { } catch (QueryException $e) {
$x++; $x++;
if ($x > 10) { if ($x > 50) {
$this->completed = false; $this->completed = false;
} }
} }

View File

@ -104,7 +104,7 @@ class PurchaseOrderService
if($force){ if($force){
$this->purchase_order->invitations->each(function ($invitation) { $this->purchase_order->invitations->each(function ($invitation) {
CreatePurchaseOrderPdf::dispatchNow($invitation); (new CreatePurchaseOrderPdf($invitation))->handle();
}); });
return $this; return $this;

View File

@ -67,7 +67,7 @@ class ApplyNumber
} catch (QueryException $e) { } catch (QueryException $e) {
$x++; $x++;
if ($x > 10) { if ($x > 50) {
$this->completed = false; $this->completed = false;
} }
} }

View File

@ -88,7 +88,7 @@ class RecurringService
$this->recurring_entity->invitations->each(function ($invitation){ $this->recurring_entity->invitations->each(function ($invitation){
UnlinkFile::dispatchNow(config('filesystems.default'), $this->recurring_entity->client->recurring_invoice_filepath($invitation) . $this->recurring_entity->numberFormatter().'.pdf'); (new UnlinkFile(config('filesystems.default'), $this->recurring_entity->client->recurring_invoice_filepath($invitation) . $this->recurring_entity->numberFormatter().'.pdf'))->handle();
}); });