Optimise queries for rendering the users dashboard page
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 32s Details
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m37s Details
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s Details

This commit is contained in:
Deon George 2024-04-14 00:47:08 +10:00
parent d6e23b9a90
commit bac41969a5
5 changed files with 68 additions and 57 deletions

View File

@ -36,15 +36,6 @@ class UserController extends Controller
->with('o',$o);
}
public function dashboard()
{
$user = Auth::user();
$user->load('systems.addresses.zone.domain.echoareas');
return view('dashboard')
->with('user',$user);
}
public function link(Request $request)
{
if ($request->post()) {

View File

@ -71,6 +71,7 @@ class System extends Model
->where('addresses.active',TRUE)
->where('zones.active',TRUE)
->where('domains.active',TRUE)
->orderBy('domains.name')
->FTNorder()
->orderBy('role','ASC');
}

View File

@ -102,7 +102,6 @@ class User extends Authenticatable implements MustVerifyEmail
*/
public function isZC(): bool
{
$this->load(['systems.addresses']);
return $this->zc()->count() > 0;
}

View File

@ -3,57 +3,77 @@
Dashboard
@endsection
@php($user->load(['systems.akas.zone.domain.echoareas','systems.akas.echoareas']))
@section('content')
<h1>{{ $user->name }}</h1>
<div class="row">
@if($user->systems->count())
<div class="col-8">
@if($user->systems->count())
<div class="row">
<div class="col-7">
<div id="network_messages"></div>
</div>
<!-- System Addresses -->
<div class="col-4">
<div class="row">
<div class="col-12">
<table class="table monotable">
<thead>
<tr><th colspan="2">System Addresses</th></tr>
</thead>
<tbody>
@foreach ($user->systems as $o)
<tr>
<th><a href="{{ url('system/addedit',[$o->id]) }}">{{ $o->name }}</a></th>
<th class="text-end">{!! $o->akas->pluck('ftn')->join('<br>') !!}</th>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div class="col-5">
<table class="table monotable">
<thead>
<tr><th colspan="2">System Addresses</th></tr>
</thead>
<tbody>
<div class="row">
<div class="col-12">
<table class="table monotable">
<thead>
<tr><th colspan="2">Available Echos</th></tr>
</thead>
<tbody>
@foreach ($user->systems as $o)
<tr>
<th><a href="{{ url('system/addedit',[$o->id]) }}">{{ $o->name }}</a></th>
<th class="text-end">{!! $o->addresses->pluck('zone.domain.echoareas')->flatten()->pluck('name')->unique()->sort()->join(', ') !!}</th>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@foreach ($user->systems->sortBy('name') as $o)
<tr>
<th><a href="{{ url('system/addedit',[$o->id]) }}">{{ $o->name }}</a></th>
<th class="text-end">
<small><small><strong>{{ $o->akas->count() }}</strong> AKAs configured</small></small><br><br>
@if ($o->akas->count())
@foreach ($o->akas as $ao)
{{ $ao->ftn }} <small>({{ $ao->security ?: '-' }})</small><br>
@endforeach
@else
-
@endif
</th>
</tr>
@endforeach
</tbody>
</table>
</div>
@else
<p>You are not linked to any BBS systems. Start <a href="{{ url('user/system/register') }}">here</a> to link to your first.</p>
@endif
</div>
</div>
<div class="row">
<div class="col-12">
<h3>Active and Available Echos</h3>
<table class="table monotable">
<tbody>
@foreach (($dl=$user
->systems
->pluck('akas')->flatten()
->pluck('zone.domain')
->unique()
->filter(function($item) { return $item->active && $item->public && $item->isManaged(); })
->sortBy('name')) as $o)
<tr>
<th class="nowrap">
<a href="{{ url('domain/view',[$o->id]) }}">{{ $o->name }}</a> <small>({{ $sec=$user->systems->pluck('akas')->flatten()->filter(function($item) use ($o) { return $item->zone->domain_id === $o->id; })->max('security') ?? '-' }})</small><br><br>
{{ ($sub=$user->systems->pluck('akas')->flatten()->pluck('echoareas')->flatten()->filter(function($item) use ($o) { return $item->domain_id === $o->id; }))->count() }} <small>Subscribed</small>
</th>
<td>
@foreach ($o->echoareas->sortBy('name') as $eo)
<span style="@if (($sec < $eo->sec_read) || ($sec < $eo->sec_write) || ! $eo->active) color: red; @elseif($sub->where('name',$eo->name)->count()) color: green; @endif">{{ $eo->name }}</span>
@endforeach
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@else
<p>You are not linked to any BBS systems. Start <a href="{{ url('user/system/register') }}">here</a> to link to your first.</p>
@endif
@endsection
@section('page-css')
@ -162,7 +182,7 @@
name: 'Networks',
colorByPoint: true,
data: [
@foreach(($xx=$user->systems->pluck('addresses')->flatten()->pluck('zone.domain')->unique(function($item) { return $item->name; })->sortBy('name')) as $do)
@foreach($dl as $do)
{
name: '{{ $do->name }}',
y: {{ $do->daily_area_stats()->sum('y') }},
@ -176,7 +196,7 @@
colorByPoint: true,
pointPlacement: 0.1,
data: [
@foreach($xx as $do)
@foreach($dl as $do)
{
name: '{{ $do->name }}',
y: {{ $do->daily_area_stats(FALSE,$user->systems)->sum('y') }},
@ -195,7 +215,7 @@
}
},
series: [
@foreach($xx as $do)
@foreach($dl as $do)
{
name: '{{ $do->name }}',
id: 'n-{{ $do->name }}',
@ -203,7 +223,7 @@
},
@endforeach
@foreach($xx as $do)
@foreach($dl as $do)
{
name: '{{ $do->name }}',
id: 'ny-{{ $do->name }}',

View File

@ -52,7 +52,7 @@ Route::get('system/view/{o}',[SystemController::class,'view'])
Route::get('search',[HomeController::class,'search']);
Route::middleware(['auth','verified','activeuser'])->group(function () {
Route::get('dashboard',[UserController::class,'dashboard']);
Route::view('dashboard','dashboard');
/* DOMAIN PATHS */
Route::view('domain','domain.home');