From 72cf09aa8525d8d525cf77311898e3f69ea6a40c Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Mon, 23 Oct 2023 12:34:57 +0100 Subject: [PATCH] Stats wrong way round. --- app/Party.php | 6 +++--- resources/views/group/view.blade.php | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/Party.php b/app/Party.php index 013cbadcc..57f4628d2 100644 --- a/app/Party.php +++ b/app/Party.php @@ -588,13 +588,13 @@ public function getEventStats($eEmissionRatio = null, $uEmissionratio = null, $i } switch ($device->repair_status) { - case 1: + case Device::REPAIR_STATUS_FIXED: $result['fixed_devices']++; break; - case 2: + case Device::REPAIR_STATUS_REPAIRABLE: $result['repairable_devices']++; break; - case 3: + case Device::REPAIR_STATUS_ENDOFLIFE: $result['dead_devices']++; break; default: diff --git a/resources/views/group/view.blade.php b/resources/views/group/view.blade.php index 929d1aa64..781f243a5 100644 --- a/resources/views/group/view.blade.php +++ b/resources/views/group/view.blade.php @@ -49,10 +49,20 @@ $showCalendar = Auth::check() && (($group && $group->isVolunteer()) || App\Helpers\Fixometer::hasRole(Auth::user(), 'Administrator')); $device_stats = [ - 'fixed' => isset($group_device_count_status[0]) ? (int) $group_device_count_status[0]->counter : 0, - 'repairable' => isset($group_device_count_status[1]) ? (int) $group_device_count_status[1]->counter : 0, - 'dead' => isset($group_device_count_status[2]) ? (int) $group_device_count_status[2]->counter : 0, - ]; + 'fixed' => 0, + 'repairable' => 0, + 'dead' => 0 + ]; + + foreach ($group_device_count_status as $count) { + if ($count->status == \App\Device::REPAIR_STATUS_FIXED) { + $device_stats['fixed'] = $count->counter; + } else if ($count->status == \App\Device::REPAIR_STATUS_REPAIRABLE) { + $device_stats['repairable'] = $count->counter; + } else if ($count->status == \App\Device::REPAIR_STATUS_ENDOFLIFE) { + $device_stats['dead'] = $count->counter; + } + } $category_clusters = [ 1 => 'Computers and Home Office',