Skip to content

Commit

Permalink
paginate queries on /scores
Browse files Browse the repository at this point in the history
  • Loading branch information
rolinh committed May 12, 2014
1 parent 05598a1 commit c74302a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion devmine/app/controllers/scores_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ class ScoresController(ApplicationController):

def index(self, db):
"""Return the list of all scores."""
return json.dumps(db.query(Score).all(), cls=ah.AlchemyEncoder)
since_id = super().get_since_id()
try:
scores = db.query(Score).filter(Score.id.between(
since_id, since_id + 100)).all()
except NoResultFound:
scores = {}
return json.dumps(scores, cls=ah.AlchemyEncoder)

def show(self, db, id):
"""Return the repository corresponding to the given id."""
Expand Down

0 comments on commit c74302a

Please sign in to comment.