From b905a812b9cdcb2c7726f1fa967672505ec6848e Mon Sep 17 00:00:00 2001 From: Augusto Gunsch Date: Mon, 18 Oct 2021 09:51:50 -0300 Subject: [PATCH] Adicionar limit e offset na query (GET /trainer) --- api/views/trainer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/views/trainer.py b/api/views/trainer.py index 6f9dc77..41ba1bd 100644 --- a/api/views/trainer.py +++ b/api/views/trainer.py @@ -34,12 +34,12 @@ def get_trainers(): if nickname_contains: return ConflictingParameters("nickname and nickname_contains are mutually exclusive") - query = Trainer.query.filter_by(nickname=nickname) + query = Trainer.query.filter_by(nickname=nickname).limit(limit).offset(offset) return trainer_schemas.dumps(query.all()) else: # se nickname_contains também está vazio, retornará todos trainers pattern = '%'+nickname_contains+'%' - query = Trainer.query.filter(Trainer.nickname.like(pattern)) + query = Trainer.query.filter(Trainer.nickname.like(pattern)).limit(limit).offset(offset) return trainer_schemas.dumps(query.all()) except NoResultFound: