-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reduce the number of queries in the dashboard by eager loading t…
…he contacts (#2138)
- Loading branch information
1 parent
5b4d889
commit a1c9361
Showing
8 changed files
with
71 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace App\Http\ViewComposers; | ||
|
||
use Illuminate\View\View; | ||
use App\Models\Instance\Instance; | ||
|
||
class InstanceViewComposer | ||
{ | ||
/** | ||
* Bind data to the view. | ||
* | ||
* @param View $view | ||
* @return void | ||
*/ | ||
public function compose(View $view) | ||
{ | ||
$instance = Instance::first(); | ||
|
||
$view->with('instance', $instance); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
<h3 class="ttu fw5 f5 pb2">{{ \App\Helpers\DateHelper::getMonthAndYear($month) }}</h3> | ||
<ul class="mb4"> | ||
@if (count(auth()->user()->account->getRemindersForMonth($month)) > 0) | ||
@foreach (auth()->user()->account->getRemindersForMonth($month) as $reminder) | ||
<li class="pb2"> | ||
<span class="ttu f6 mr2 black-60">{{ \App\Helpers\DateHelper::getShortDateWithoutYear($reminder->next_expected_date) }}</span> | ||
<span> | ||
@foreach($remindersList as $month => $reminders) | ||
<h3 class="ttu fw5 f5 pb2">{{ \App\Helpers\DateHelper::getMonthAndYear($month) }}</h3> | ||
<ul class="mb4"> | ||
@if(count($reminders) > 0) | ||
@foreach($reminders as $reminder) | ||
<li class="pb2"> | ||
<span class="ttu f6 mr2 black-60">{{ \App\Helpers\DateHelper::getShortDateWithoutYear($reminder->next_expected_date) }}</span> | ||
<span> | ||
@if ($reminder->contact->is_partial) | ||
|
||
@if ($reminder->contact->is_partial) | ||
@php($relatedRealContact = $reminder->contact->getRelatedRealContact()) | ||
<a href="{{ route('people.show', $relatedRealContact) }}">{{ $relatedRealContact->getIncompleteName() }}</a> | ||
|
||
<a href="{{ route('people.show', $reminder->contact->getRelatedRealContact()) }}">{{ $reminder->contact->getRelatedRealContact()->getIncompleteName() }}</a> | ||
@else | ||
|
||
@else | ||
|
||
<a href="{{ route('people.show', $reminder->contact) }}">{{ $reminder->contact->getIncompleteName() }}</a> | ||
<a href="{{ route('people.show', $reminder->contact) }}">{{ $reminder->contact->getIncompleteName() }}</a> | ||
|
||
@endif | ||
</span> | ||
{{ $reminder->title }} | ||
</li> | ||
@endforeach | ||
@else | ||
<p>{{ trans('dashboard.reminders_none') }}</p> | ||
@endif | ||
</span> | ||
{{ $reminder->title }} | ||
</li> | ||
@endforeach | ||
@else | ||
<p>{{ trans('dashboard.reminders_none') }}</p> | ||
@endif | ||
</ul> | ||
</ul> | ||
@endforeach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters