Skip to content

Commit 10a711d

Browse files
authored
Production (#33)
* Fix campaigns not saving * Fix #2 * Added /players endpoint * Fix bug with global players endpoint returning always the latest when time was given
1 parent 567b4ba commit 10a711d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/Http/Controllers/Api/PlanetStatusController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,17 @@ public function playersGlobal(Request $request) {
9797

9898
if (!$request->has('time')) {
9999
$time = Carbon::now();
100+
error_log($time);
100101
} else {
101102
$time = Carbon::parse($data['time']);
103+
error_log($time);
102104
}
103105

104-
$players = Planet::with(['history' => function (Builder $q) use ($time) {
106+
$planets = Planet::with(['history' => function (Builder $q) use ($time) {
105107
$q->latest()->where('created_at', '<', $time)->limit(1);
106-
}])->sum('players');
108+
}])->get();
109+
110+
$players = $planets->pluck('history')->OneEntryArrayList()->sum('players');
107111

108112
return response()->json([
109113
"count" => $players

0 commit comments

Comments
 (0)