Skip to content

Commit 9f412b2

Browse files
authored
⚡ improve performance of polyline endpoint (#4584)
1 parent b4b5af1 commit 9f412b2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/Http/Controllers/API/v1/StatusController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,8 @@ public function getPolyline(string $parameters): JsonResource
733733
)]
734734
public function getStopovers(string $parameters): JsonResponse
735735
{
736-
$tripIds = explode(',', $parameters, 50);
737-
$trips = Trip::whereIn('id', $tripIds)->get()->mapWithKeys(function ($trip) {
736+
$tripIds = array_unique(explode(',', $parameters, 50));
737+
$trips = Trip::with('stopovers.station')->whereIn('id', $tripIds)->get()->mapWithKeys(function ($trip) {
738738
return [$trip->id => StopoverResource::collection($trip->stopovers)];
739739
});
740740

0 commit comments

Comments
 (0)