From: Michael Tremer Date: Mon, 17 Oct 2022 16:23:48 +0000 (+0000) Subject: builds: Implement len() to count how many builds there are X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc5f9e041f5aeefd356766d1c5f873dda901718e;p=pbs.git builds: Implement len() to count how many builds there are Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/builds.py b/src/buildservice/builds.py index 5afe7db4..c2acff4d 100644 --- a/src/buildservice/builds.py +++ b/src/buildservice/builds.py @@ -26,6 +26,19 @@ class Builds(base.Object): for row in res: yield Build(self.backend, row.id, data=row) + def __len__(self): + res = self.db.get(""" + SELECT + COUNT(*) as builds + FROM + builds + WHERE + deleted_at IS NULL + """, + ) + + return res.builds + def get_by_id(self, id): return self._get_build(""" SELECT