]> git.ipfire.org Git - pbs.git/commitdiff
builders: Fix showing running jobs
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Jan 2025 15:04:41 +0000 (15:04 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Jan 2025 15:04:41 +0000 (15:04 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builders.py
src/templates/builders/show.html

index 03c53488eff0c45476a98a8adab64d1d6a1f2cf5..76496b760ee96caaddf5edef297ed2774f386794 100644 (file)
@@ -493,29 +493,26 @@ class Builder(database.Base, database.BackendMixin, database.SoftDeleteMixin):
        def can_build(self, job):
                return job.arch in self.supported_arches
 
-       # Jobs
+       # Running Jobs
 
-       @property
-       def jobs(self):
-               jobs = self.backend.jobs._get_jobs("""
-                       SELECT
-                               jobs.*
-                       FROM
-                               jobs
-                       WHERE
-                               deleted_at IS NULL
-                       AND
-                               started_at IS NOT NULL
-                       AND
-                               finished_at IS NULL
-                       AND
-                               builder_id = %s
-                       ORDER BY
-                               started_at DESC""",
-                       self.id,
+       async def get_running_jobs(self):
+               stmt = (
+                       sqlalchemy
+                       .select(
+                               jobs.Job,
+                       )
+                       .where(
+                               jobs.Job.deleted_at == None,
+                               jobs.Job.started_at != None,
+                               jobs.Job.finished_at == None,
+                               jobs.Job.builder == self,
+                       )
+                       .order_by(
+                               jobs.Job.started_at.desc(),
+                       )
                )
 
-               return list(jobs)
+               return await self.db.fetch_as_list(stmt)
 
        # Max Jobs
 
index f253f5c9e4c62b9d17d9d077169d566da780033b..2e4b4effe52bf68552db724ec5e606b58dcf6b22 100644 (file)
                </section>
        {% endif %}
 
-       {% if builder.jobs %}
+       {# Show any running jobs #}
+       {% set jobs = builder.get_running_jobs() %}
+       {% if jobs %}
                <section class="section">
                        <div class="container">
                                <h5 class="subtitle is-5">{{ _("Running Jobs") }}</h5>
 
-                               {{ JobsList(builder.jobs) }}
+                               {{ JobList(jobs) }}
                        </div>
                </section>
        {% endif %}