From: Michael Tremer Date: Tue, 1 Aug 2023 16:31:07 +0000 (+0000) Subject: index: Show recently finished jobs instead of pending ones X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f72ca4461cd624ace4b6cc6bea9075aa0974240d;p=pbs.git index: Show recently finished jobs instead of pending ones Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/jobs.py b/src/buildservice/jobs.py index 8ee57b67..9f806fa8 100644 --- a/src/buildservice/jobs.py +++ b/src/buildservice/jobs.py @@ -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): diff --git a/src/templates/index.html b/src/templates/index.html index 2755dc68..5a57c4e6 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -16,38 +16,22 @@ - {# 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 %}
-
- {# Running Jobs #} - {% if running_jobs %} -
-
-

{{ _("Running Jobs") }}

-

{{ len(running_jobs) }}

-
-
- {% end %} + {% module JobsQueue(running_jobs + finished_jobs) %} - {# Queue Length #} - {% if queue_length %} -
-
-

{{ _("Queued Jobs") }}

-

- - {{ queue_length }} - -

-
-
- {% end %} -
+
diff --git a/src/web/handlers.py b/src/web/handlers.py index a2609dc8..4074c5a0 100644 --- a/src/web/handlers.py +++ b/src/web/handlers.py @@ -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),