Verified Commit 1d86b3e2 authored by Kevin Morris's avatar Kevin Morris
Browse files

fix: use a transaction for package query; remove refresh

Closes #284



Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent 4e641d94
......@@ -138,20 +138,20 @@ def updated_packages(limit: int = 0,
# If we already have a cache, deserialize it and return.
return orjson.loads(packages)
query = db.query(models.Package).join(models.PackageBase).filter(
models.PackageBase.PackagerUID.isnot(None)
).order_by(
models.PackageBase.ModifiedTS.desc()
)
with db.begin():
query = db.query(models.Package).join(models.PackageBase).filter(
models.PackageBase.PackagerUID.isnot(None)
).order_by(
models.PackageBase.ModifiedTS.desc()
)
if limit:
query = query.limit(limit)
if limit:
query = query.limit(limit)
packages = []
for pkg in query:
# For each Package returned by the query, append a dict
# containing Package columns we're interested in.
db.refresh(pkg)
packages.append({
"Name": pkg.Name,
"Version": pkg.Version,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment