From: Michael Tremer Date: Fri, 24 Jan 2025 11:19:37 +0000 (+0000) Subject: builds: Make the group a relationship again X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d7d6f7b4295de3ced626ac393748c3eca153584d;p=pbs.git builds: Make the group a relationship again This is the only way to easily work with the group; to assign it when we create a build. Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/builds.py b/src/buildservice/builds.py index b57feec2..ba80cfe4 100644 --- a/src/buildservice/builds.py +++ b/src/buildservice/builds.py @@ -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 diff --git a/src/templates/builds/show.html b/src/templates/builds/show.html index b538d885..ca98cf15 100644 --- a/src/templates/builds/show.html +++ b/src/templates/builds/show.html @@ -12,9 +12,6 @@ {% block title %}{{ _("Build") }} - {{ build }}{% endblock %} {% block body %} - {# Fetch the group #} - {% set group = build.get_group() %} -
{{ _("Test Build") }} - - {{ group.tested_build }} + + {{ build.group.tested_build }} {% else %}