Add limit clause to motolite events endpoint #730
This commit is contained in:
parent
9b7e0e55a7
commit
059bda9bf6
1 changed files with 6 additions and 2 deletions
|
|
@ -13,15 +13,19 @@ class MotoliteEventController extends ApiController
|
|||
public function getEvents(Request $req)
|
||||
{
|
||||
// validate params
|
||||
$validity = $this->validateRequest($req);
|
||||
$validity = $this->validateRequest($req, [
|
||||
'limit',
|
||||
]);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
$limit = $req->query->get('limit');
|
||||
|
||||
// get all events
|
||||
$results = $this->em->getRepository(MotoliteEvent::class)
|
||||
->findBy([], ['event_time' => 'asc']);
|
||||
->findBy([], ['event_time' => 'asc'], $limit);
|
||||
|
||||
if (empty($results)) {
|
||||
return new ApiResponse(false, 'No events available.');
|
||||
|
|
|
|||
Loading…
Reference in a new issue