]> git.ipfire.org Git - pbs.git/commitdiff
index: Show recently finished jobs instead of pending ones
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Aug 2023 16:31:07 +0000 (16:31 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Aug 2023 16:31:07 +0000 (16:31 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/jobs.py
src/templates/index.html
src/web/handlers.py

index 8ee57b67d24ad3ad56fbbfa50729ea5618d6b0db..9f806fa816dfa8ad5d26b0159bb2038003b277ac 100644 (file)
@@ -104,10 +104,10 @@ class Jobs(base.Object):
 
        def get_finished(self, failed_only=False, limit=None, offset=None):
                """
-                       Returns an iterator of all finished jobs
+                       Returns a list of all finished jobs
                """
                if failed_only:
-                       return self._get_jobs("""
+                       jobs = self._get_jobs("""
                                SELECT
                                        *
                                FROM
@@ -126,22 +126,25 @@ class Jobs(base.Object):
                                        %s
                        """, limit, offset)
 
-               return self._get_jobs("""
-                       SELECT
-                               *
-                       FROM
-                               jobs
-                       WHERE
-                               deleted_at IS NULL
-                       AND
-                               finished_at IS NOT NULL
-                       ORDER BY
-                               finished_at DESC
-                       LIMIT
-                               %s
-                       OFFSET
-                               %s
-               """, limit, offset)
+               else:
+                       jobs = self._get_jobs("""
+                               SELECT
+                                       *
+                               FROM
+                                       jobs
+                               WHERE
+                                       deleted_at IS NULL
+                               AND
+                                       finished_at IS NOT NULL
+                               ORDER BY
+                                       finished_at DESC
+                               LIMIT
+                                       %s
+                               OFFSET
+                                       %s
+                       """, limit, offset)
+
+               return list(jobs)
 
        @property
        def running(self):
index 2755dc685b3f7d0c9a371ebf70a0ca05dcfc3104..5a57c4e6afc8a7efa48d53ccdad2b5d883a23d23 100644 (file)
                </div>
        </section>
 
-       {# Show a status bar with running/queued jobs #}
-       {% if running_jobs or queued_jobs %}
+       {# Show a status bar with running/finished jobs #}
+       {% if running_jobs or finished_jobs %}
                <section class="hero is-light">
                        <div class="hero-body">
                                <div class="container">
-                                       <div class="level">
-                                               {# Running Jobs #}
-                                               {% if running_jobs %}
-                                                       <div class="level-item has-text-centered">
-                                                               <div>
-                                                                       <p class="heading">{{ _("Running Jobs") }}</p>
-                                                                       <p class="title">{{ len(running_jobs) }}</p>
-                                                               </div>
-                                                       </div>
-                                               {% end %}
+                                       {% module JobsQueue(running_jobs + finished_jobs) %}
 
-                                               {# Queue Length #}
-                                               {% if queue_length %}
-                                                       <div class="level-item has-text-centered">
-                                                               <div>
-                                                                       <p class="heading">{{ _("Queued Jobs") }}</p>
-                                                                       <p class="title">
-                                                                               <a href="/jobs/queue">
-                                                                                       {{ queue_length }}
-                                                                               </a>
-                                                                       </p>
-                                                               </div>
-                                                       </div>
-                                               {% end %}
-                                       </div>
+                                       <div class="buttons is-centered">
+                                               <a class="button is-light" href="/jobs/queue">
+                                                       {{ _("Queued Jobs") }} <span class="tag">{{ queue_length }}</span>
+                                               </a>
 
-                                       {% module JobsQueue(running_jobs + queued_jobs) %}
+                                               <a class="button is-light" href="/jobs">
+                                                       {{ _("Recently Finished Jobs") }}
+                                               </a>
+                                       </div>
                                </div>
                        </div>
                </section>
index a2609dc88388b865a133fe7516c5a08d08df0968..4074c5a0b9c254318d350daf1b19f75af0382889 100644 (file)
@@ -10,8 +10,8 @@ class IndexHandler(base.BaseHandler):
                        # Fetch all running jobs
                        "running_jobs" : self.backend.jobs.running,
 
-                       # Fetch queued jobs
-                       "queued_jobs" : self.backend.jobs.queue.get_jobs(limit=3),
+                       # Fetch finished jobs
+                       "finished_jobs" : self.backend.jobs.get_finished(limit=8),
 
                        # Fetch the total length of the queue
                        "queue_length" : len(self.backend.jobs.queue),