diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index 14384940..2d2a6bb2 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -87,6 +87,12 @@ class ApiController extends Controller { $transforms[] = array($this->timelineQuery, 'transformTagFilter', $tagName); } + // Limit number of responses for day query + $limit = $this->request->getParam('limit'); + if ($limit) { + $transforms[] = array($this->timelineQuery, 'transformLimitDay', intval($limit)); + } + return $transforms; } diff --git a/lib/Db/TimelineQueryFilters.php b/lib/Db/TimelineQueryFilters.php index bfdd08da..d1e644ee 100644 --- a/lib/Db/TimelineQueryFilters.php +++ b/lib/Db/TimelineQueryFilters.php @@ -44,4 +44,8 @@ trait TimelineQueryFilters { public function transformVideoFilter(IQueryBuilder &$query, string $userId) { $query->andWhere($query->expr()->eq('m.isvideo', $query->createNamedParameter('1'))); } + + public function transformLimitDay(IQueryBuilder &$query, string $userId, int $limit) { + $query->setMaxResults($limit); + } } \ No newline at end of file