Support SQLite dashboard time calculations

This commit is contained in:
2026-06-03 07:02:17 +05:00
parent 932b37c7f6
commit 036489c8d2
3 changed files with 21 additions and 2 deletions
+2 -1
View File
@@ -7,6 +7,7 @@ use App\Models\RequestType;
use App\Models\ServiceRequest;
use App\Models\Status;
use App\Models\User;
use App\Support\DatabaseExpression;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
@@ -63,7 +64,7 @@ class ReportService
$overdue = (clone $query)->overdue()->count();
$avgResolution = (clone $query)
->whereNotNull('completed_at')
->selectRaw('AVG(TIMESTAMPDIFF(HOUR, created_at, completed_at)) as avg_hours')
->selectRaw('AVG('.DatabaseExpression::hoursBetween('created_at', 'completed_at').') as avg_hours')
->value('avg_hours');
$rating = (clone $query)->whereNotNull('client_rating')->avg('client_rating');