Change sorting on graphs so that date is in date order

This commit is contained in:
Deon George 2022-01-14 19:15:37 +11:00
parent 81b9ebfe6b
commit e78e79a8f5

View File

@ -77,13 +77,14 @@ class Domain extends Model
->when($systems?->count(),function($query) use ($systems) { return $query->whereIn('fftn_id',$systems->pluck('addresses')->flatten()->pluck('id')->toArray()); }) ->when($systems?->count(),function($query) use ($systems) { return $query->whereIn('fftn_id',$systems->pluck('addresses')->flatten()->pluck('id')->toArray()); })
->where('datetime','>=',Carbon::now()->subMonths(self::STATS_MONTHS)->startOfMonth()) ->where('datetime','>=',Carbon::now()->subMonths(self::STATS_MONTHS)->startOfMonth())
->groupBy(['echoarea_id','echoareas.name','date']) ->groupBy(['echoarea_id','echoareas.name','date'])
->orderBy('echoareas.name')
->orderBy('date') ->orderBy('date')
->orderBy('echoareas.name')
->with(['echoarea']) ->with(['echoarea'])
->get(); ->get();
if ($byarea) if ($byarea)
return $echostats return $echostats
->sortBy('name')
->groupBy(['echoarea_id']) ->groupBy(['echoarea_id'])
->map(function($item,$key) { ->map(function($item,$key) {
return [ return [