Cache some calls to Mongo for performance

This commit is contained in:
Deon George
2021-11-26 16:58:50 +11:00
parent be886d9e4b
commit 6acc8ee407
3 changed files with 62 additions and 18 deletions

View File

@@ -50,10 +50,10 @@
<tr>
<td style="width: 15%;"><a href="{{ url('ftn/echoarea/addedit',[$oo->id]) }}">{{ $oo->name }}</a></td>
<td>{{ $oo->description }}</td>
<td style="width: 15%;">{{ ($x=$oo->echomail()->orderBy('datetime','DESC')->first()) ? $x->datetime->format('Y-m-d H:i') : '-' }}</td>
<td class="text-end">{{ number_format($oo->echomail()->where('datetime','>=',Carbon::now()->subDay())->count()) }}</td>
<td class="text-end">{{ number_format($oo->echomail()->where('datetime','>=',Carbon::now()->subWeek())->count()) }}</td>
<td class="text-end">{{ number_format($oo->echomail()->where('datetime','>=',Carbon::now()->subMonth())->count()) }}</td>
<td style="width: 15%;">{{ $oo->last_message ? $oo->last_message->format('Y-m-d H:i') : '-' }}</td>
<td class="text-end">{{ number_format($oo->messages_count(1)) }}</td>
<td class="text-end">{{ number_format($oo->messages_count(7)) }}</td>
<td class="text-end">{{ number_format($oo->messages_count(30)) }}</td>
</tr>
@endforeach
</tbody>
@@ -276,7 +276,7 @@
}
},
series: [
@foreach($o->echoareas as $oo)
@foreach($o->echoareas->sortBy('name') as $oo)
{
name: '{{ $oo->name }}',
data: {!! $o->daily_echoarea_stats($oo) !!},