""", uuid,
)
- def get_by_name(self, name, type=None, user=None, limit=None, offset=None):
- args = [name,]
- conditions = [
- "packages.name = %s",
- ]
-
- if type:
- conditions.append("builds.type = %s")
- args.append(type)
-
- or_conditions = []
- if user and not user.is_admin():
- or_conditions.append("builds.owner_id = %s")
- args.append(user.id)
-
- query = "SELECT builds.* AS id FROM builds \
- JOIN packages ON builds.pkg_id = packages.id"
-
- if or_conditions:
- conditions.append(" OR ".join(or_conditions))
-
- if conditions:
- query += " WHERE %s" % " AND ".join(conditions)
-
- if type == "release":
- query += " ORDER BY packages.name,packages.epoch,packages.version,packages.release,id ASC"
- elif type == "scratch":
- query += " ORDER BY created_at DESC"
-
- query += " LIMIT %s OFFSET %s"
- args.extend([offset, limit])
-
- return [Build(self.backend, b.id, b) for b in self.db.query(query, *args)]
-
def get_latest_by_name(self, name):
"""
Returns the latest build that matches the package name