return [self.get_by_id(b.id, b) for b in self.db.query(query)]
- def get_by_user(self, user, type=None, public=None):
+ def get_by_user(self, user, type=None):
args = []
conditions = []
elif not type or type == "release":
pass # TODO
- if public is True:
- conditions.append("public = 'Y'")
- elif public is False:
- conditions.append("public = 'N'")
-
query = "SELECT builds.* AS id FROM builds \
JOIN packages ON builds.pkg_id = packages.id"
return builds
- def get_by_name(self, name, type=None, public=None, user=None, limit=None, offset=None):
+ def get_by_name(self, name, type=None, user=None, limit=None, offset=None):
args = [name,]
conditions = [
"packages.name = %s",
args.append(type)
or_conditions = []
- if public is True:
- or_conditions.append("public = 'Y'")
- elif public is False:
- or_conditions.append("public = 'N'")
-
if user and not user.is_admin():
or_conditions.append("builds.owner_id = %s")
args.append(user.id)
return [Build(self.backend, b.id, b) for b in self.db.query(query, *args)]
- def get_latest_by_name(self, name, type=None, public=None):
+ def get_latest_by_name(self, name, type=None):
query = "\
SELECT * FROM builds \
LEFT JOIN builds_latest ON builds.id = builds_latest.build_id \
query += " AND builds_latest.build_type = %s"
args.append(type)
- if public is True:
- query += " AND builds.public = %s"
- args.append("Y")
- elif public is False:
- query += " AND builds.public = %s"
- args.append("N")
-
# Get the last one only.
# Prefer release builds over scratch builds.
query += "\
if res:
return Build(self.backend, res.id, res)
- def get_active_builds(self, name, public=None):
+ def get_active_builds(self, name):
query = "\
SELECT * FROM builds \
LEFT JOIN builds_latest ON builds.id = builds_latest.build_id \
WHERE builds_latest.package_name = %s AND builds.type = %s"
args = [name, "release"]
- if public is True:
- query += " AND builds.public = %s"
- args.append("Y")
- elif public is False:
- query += " AND builds.public = %s"
- args.append("N")
-
builds = []
for row in self.db.query(query, *args):
b = Build(self.backend, row.id, row)
return build
- def get_changelog(self, name, public=None, limit=5, offset=0):
+ def get_changelog(self, name, limit=5, offset=0):
query = "SELECT builds.* FROM builds \
JOIN packages ON builds.pkg_id = packages.id \
WHERE \
packages.name = %s"
args = ["release", name,]
- if public == True:
- query += " AND builds.public = %s"
- args.append("Y")
- elif public == False:
- query += " AND builds.public = %s"
- args.append("N")
-
query += " ORDER BY builds.time_created DESC"
if limit:
def date(self):
return self.created.date()
- @property
- def public(self):
- """
- Is this build public?
- """
- return self.data.public
-
@lazy_property
def size(self):
"""