Add limit transform

cache
Varun Patil 2022-10-06 14:44:14 -07:00
parent 994320f78e
commit 66f479844e
2 changed files with 10 additions and 0 deletions

View File

@ -87,6 +87,12 @@ class ApiController extends Controller {
$transforms[] = array($this->timelineQuery, 'transformTagFilter', $tagName); $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; return $transforms;
} }

View File

@ -44,4 +44,8 @@ trait TimelineQueryFilters {
public function transformVideoFilter(IQueryBuilder &$query, string $userId) { public function transformVideoFilter(IQueryBuilder &$query, string $userId) {
$query->andWhere($query->expr()->eq('m.isvideo', $query->createNamedParameter('1'))); $query->andWhere($query->expr()->eq('m.isvideo', $query->createNamedParameter('1')));
} }
public function transformLimitDay(IQueryBuilder &$query, string $userId, int $limit) {
$query->setMaxResults($limit);
}
} }