name,
)
- def get_recent(self, limit=None):
+ def get_recent(self, limit=None, offset=None):
"""
Returns the most recent (non-test) builds
"""
test IS FALSE
ORDER BY
created_at DESC
- LIMIT %s""",
- limit,
+ LIMIT
+ %s
+ OFFSET
+ %s""",
+ limit, offset,
)
return list(builds)
{% module BuildsList(builds[date]) %}
</div>
{% end %}
+
+ <div class="block">
+ <nav class="pagination is-centered" role="navigation" aria-label="pagination">
+ <a class="pagination-previous {% if not offset %}is-disabled{% end %}"
+ href="/builds?offset={{ offset - limit }}&limit={{ limit }}{% if user %}&user={{ user.name }}{% end %}">
+ {{ _("Previous Page") }}
+ </a>
+
+ <a class="pagination-next" href="/builds?offset={{ offset + limit }}&limit={{ limit }}{% if user %}&user={{ user.name }}{% end %}">
+ {{ _("Next Page") }}
+ </a>
+ </nav>
+ </div>
</div>
</section>
{% end block %}
class IndexHandler(base.BaseHandler):
def get(self):
+ # Pagination
+ offset = self.get_argument_int("offset", None) or 0
+ limit = self.get_argument_int("limit", None) or 25
+
# Filters
user = self.get_argument_user("user", None)
# Fetch the most recent builds
if user:
- builds = self.backend.builds.get_by_user(user, limit=25)
+ builds = self.backend.builds.get_by_user(user, limit=limit, offset=offset)
else:
- builds = self.backend.builds.get_recent(limit=25)
+ builds = self.backend.builds.get_recent(limit=limit, offset=offset)
# Group builds by date
builds = misc.group(builds, lambda build: build.created_at.date())
- self.render("builds/index.html", builds=builds, user=user)
+ self.render("builds/index.html", builds=builds, user=user,
+ limit=limit, offset=offset)
class ShowHandler(base.BaseHandler):