1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-06 03:02:34 +01:00

Performance improvements - PDF generation (#3521)

* Improve performance of PDF building

* Clean up

* Fixes for tests

* Minor fixes
This commit is contained in:
David Bomba 2020-03-25 00:25:20 +11:00 committed by GitHub
parent cdc3ef12c2
commit 90cb69f8a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 13 deletions

View File

@ -92,11 +92,14 @@ class InvoiceController extends Controller
*/ */
public function bulk(ProcessInvoicesInBulkRequest $request) public function bulk(ProcessInvoicesInBulkRequest $request)
{ {
// \Log::error($request->all());
$transformed_ids = $this->transformKeys($request->invoices); $transformed_ids = $this->transformKeys($request->invoices);
if (request()->input('action') == 'payment') { //\Log::error($transformed_ids);
if ($request->input('action') == 'payment') {
return $this->makePayment((array)$transformed_ids); return $this->makePayment((array)$transformed_ids);
} elseif (request()->input('action') == 'download') { } elseif ($request->input('action') == 'download') {
return $this->downloadInvoicePDF((array)$transformed_ids); return $this->downloadInvoicePDF((array)$transformed_ids);
} }
@ -109,6 +112,7 @@ class InvoiceController extends Controller
$invoices = Invoice::whereIn('id', $ids) $invoices = Invoice::whereIn('id', $ids)
->whereClientId(auth()->user()->client->id) ->whereClientId(auth()->user()->client->id)
->get(); ->get();
//\Log::error($invoices);
$total = $invoices->sum('balance'); $total = $invoices->sum('balance');

View File

@ -151,7 +151,7 @@ class UserController extends BaseController
*/ */
public function create(CreateUserRequest $request) public function create(CreateUserRequest $request)
{ {
$user = UserFactory::create(); $user = UserFactory::create(auth()->user()->account->id);
return $this->itemResponse($user); return $this->itemResponse($user);
} }

View File

@ -47,7 +47,7 @@ class QueryLogging
$count = count($queries); $count = count($queries);
$timeEnd = microtime(true); $timeEnd = microtime(true);
$time = $timeEnd - $timeStart; $time = $timeEnd - $timeStart;
Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time); // Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time);
// if($count > 50) // if($count > 50)
// Log::info($queries); // Log::info($queries);

View File

@ -80,7 +80,7 @@ class StoreUserRequest extends Request
$user = MultiDB::hasUser(['email' => $this->input('email')]); $user = MultiDB::hasUser(['email' => $this->input('email')]);
if (!$user) { if (!$user) {
$user = UserFactory::create(); $user = UserFactory::create(auth()->user()->account->id);
} }
return $user; return $user;

View File

@ -689,7 +689,7 @@ class Import implements ShouldQueue
$user = MultiDB::hasUser(['email' => $data]); $user = MultiDB::hasUser(['email' => $data]);
if (!$user) { if (!$user) {
$user = UserFactory::create(); $user = UserFactory::create($this->company->account->id);
} }
return $user; return $user;

View File

@ -47,14 +47,14 @@ trait MakesInvoiceHtml
$data = []; $data = [];
$data['entity'] = $entity; $data['entity'] = $entity;
$data['lang'] = $client->preferredLocale(); $data['lang'] = $client->preferredLocale();
$data['includes'] = $this->parseLabelsAndValues($labels, $values, $designer->init()->getIncludes()->getHtml()); $data['includes'] = $designer->init()->getIncludes()->getHtml();
$data['header'] = $this->parseLabelsAndValues($labels, $values, $designer->init()->getHeader()->getHtml()); $data['header'] = $designer->init()->getHeader()->getHtml();
$data['body'] = $this->parseLabelsAndValues($labels, $values, $designer->init()->getBody()->getHtml()); $data['body'] = $designer->init()->getBody()->getHtml();
$data['footer'] = $this->parseLabelsAndValues($labels, $values, $designer->init()->getFooter()->getHtml()); $data['footer'] = $designer->init()->getFooter()->getHtml();
$html = view('pdf.stub', $data)->render(); $html = view('pdf.stub', $data)->render();
// \Log::error($html); $html = $this->parseLabelsAndValues($labels, $values, $html);
return $html; return $html;
} }

View File

@ -91,7 +91,7 @@ class UserTest extends TestCase
public function testUserAttachAndDetach() public function testUserAttachAndDetach()
{ {
$user = UserFactory::create(); $user = UserFactory::create($this->account->id);
$user->first_name = 'Test'; $user->first_name = 'Test';
$user->last_name = 'Palloni'; $user->last_name = 'Palloni';
$user->save(); $user->save();
@ -149,7 +149,7 @@ class UserTest extends TestCase
$cu->save(); $cu->save();
/*Create New Blank User and Attach to Company 2*/ /*Create New Blank User and Attach to Company 2*/
$new_user = UserFactory::create(); $new_user = UserFactory::create($this->account->id);
$new_user->first_name = 'Test'; $new_user->first_name = 'Test';
$new_user->last_name = 'Palloni'; $new_user->last_name = 'Palloni';
$new_user->save(); $new_user->save();