return await self.db.fetch_one(stmt)
- @lazy_property
- def total_builds(self):
- res = self.db.get("""
- SELECT
- COUNT(*) AS count
- FROM
- repository_builds
- LEFT JOIN
- builds ON repository_builds.build_id = builds.id
- WHERE
- builds.deleted_at IS NULL
- AND
- repository_builds.repo_id = %s
- AND
- repository_builds.removed_at IS NULL
- """, self.id,
+ async def get_total_builds(self):
+ """
+ Return the total number of builds in this repository
+ """
+ stmt = (
+ sqlalchemy
+ .select(
+ sqlalchemy.func.count().label("total_builds"),
+ )
+ .select_from(RepoBuild)
+ .join(
+ builds.Build,
+ builds.Build.id == RepoBuild.build_id,
+ )
+ .where(
+ builds.Build.deleted_at == None,
+
+ RepoBuild.repo == self,
+ RepoBuild.removed_at == None,
+ )
)
- return res.count or 0
+ return await self.db.select_one(stmt, "total_builds")
async def get_packages(self, arch):
if arch == "src":
<div class="block">
<nav class="level">
+ {# Total Builds #}
+ {% set total_builds = repo.get_total_builds() %}
+
<div class="level-item has-text-centered">
<div>
<p class="heading">
{{ _("Total Builds") }}
</p>
<p class="title">
- {{ repo.total_builds }}
+ {{ total_builds }}
</p>
</div>
</div>
+ {# Total Size #}
+ {% set total_size = repo.get_total_size() %}
+
<div class="level-item has-text-centered">
<div>
<p class="heading">
{{ _("Total Size") }}
</p>
<p class="title">
- {{ repo.get_total_size() | filesizeformat(binary=True) }}
+ {{ total_size | filesizeformat(binary=True) }}
</p>
</div>
</div>