]> git.ipfire.org Git - pbs.git/commitdiff
builds: Make the group a relationship again
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 24 Jan 2025 11:19:37 +0000 (11:19 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 24 Jan 2025 11:19:37 +0000 (11:19 +0000)
This is the only way to easily work with the group; to assign it when we
create a build.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builds.py
src/templates/builds/show.html

index b57feec25d80800c9bd254b88fe11b834b7e6fd6..ba80cfe4898874f6a7e771ebc658070b35b7d993 100644 (file)
@@ -467,22 +467,9 @@ class Build(database.Base, database.BackendMixin, database.SoftDeleteMixin):
 
        # Group
 
-       async def get_group(self):
-               """
-                       Returns the build group this build is in
-               """
-               stmt = (
-                       sqlalchemy
-                       .select(
-                               BuildGroup,
-                       )
-                       .where(
-                               BuildGroup.deleted_at == None,
-                               BuildGroup.id == self.group_id,
-                       )
-               )
-
-               return await self.db.fetch_one(stmt)
+       group = sqlalchemy.orm.relationship(
+               "BuildGroup", foreign_keys=[group_id], lazy="selectin",
+       )
 
        # Severity
 
index b538d8858d85a0b5a841815f3793b8d806cc5ab1..ca98cf1568056cdfb02c41f55d09cd1ad5f2bf59 100644 (file)
@@ -12,9 +12,6 @@
 {% block title %}{{ _("Build") }} - {{ build }}{% endblock %}
 
 {% block body %}
-       {# Fetch the group #}
-       {% set group = build.get_group() %}
-
        <section class="hero
                {% if build.is_successful() %}
                        is-success
@@ -47,8 +44,8 @@
                                                        <h6 class="subtitle is-6">
                                                                <span class="tag is-warning">{{ _("Test Build") }}</span>
 
-                                                               <a href="/builds/{{ group.tested_build.uuid }}">
-                                                                       {{ group.tested_build }}
+                                                               <a href="/builds/{{ build.group.tested_build.uuid }}">
+                                                                       {{ build.group.tested_build }}
                                                                </a>
                                                        </h6>
                                                {% else %}