]> git.ipfire.org Git - pbs.git/commitdiff
jobs: Group by date
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Aug 2023 15:50:06 +0000 (15:50 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Aug 2023 15:50:06 +0000 (15:50 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/templates/jobs/index.html
src/web/jobs.py

index 4c896b75013d804f890410e84adfc02e67a7039e..c9fd8d0e0b43f716f878abc08036769c4cd261f7 100644 (file)
 
        <section class="section">
                <div class="container">
-                       <div class="block">
-                               {% module JobsQueue(jobs) %}
-                       </div>
+                       {# Render all jobs #}
+                       {% for date in jobs %}
+                               <div class="block">
+                                       <h4 class="title is-4">{{ locale.format_day(date) }}</h4>
+
+                                       {% module JobsQueue(jobs[date]) %}
+                               </div>
+                       {% end %}
 
                        <div class="block">
                                <nav class="pagination is-centered" role="navigation" aria-label="pagination">
index 303a42fa085b0304fd1698f3b26ab4cabc3a1b65..9e214db892470028c0434068fecaaca621660c38 100644 (file)
@@ -4,6 +4,7 @@ import logging
 import tornado.web
 import tornado.websocket
 
+from .. import misc
 from . import base
 from . import ui_modules
 
@@ -148,6 +149,9 @@ class IndexHandler(base.BaseHandler):
                with self.db.transaction():
                        jobs = self.backend.jobs.get_finished(limit=limit, offset=offset)
 
+                       # Group jobs by date
+                       jobs = misc.group(jobs, lambda job: job.finished_at.date())
+
                self.render("jobs/index.html", jobs=jobs, limit=limit, offset=offset)