mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix: use a transaction for package query; remove refresh
Closes #284 Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
4e641d945c
commit
1d86b3e210
1 changed files with 8 additions and 8 deletions
|
@ -138,20 +138,20 @@ def updated_packages(limit: int = 0,
|
||||||
# If we already have a cache, deserialize it and return.
|
# If we already have a cache, deserialize it and return.
|
||||||
return orjson.loads(packages)
|
return orjson.loads(packages)
|
||||||
|
|
||||||
query = db.query(models.Package).join(models.PackageBase).filter(
|
with db.begin():
|
||||||
models.PackageBase.PackagerUID.isnot(None)
|
query = db.query(models.Package).join(models.PackageBase).filter(
|
||||||
).order_by(
|
models.PackageBase.PackagerUID.isnot(None)
|
||||||
models.PackageBase.ModifiedTS.desc()
|
).order_by(
|
||||||
)
|
models.PackageBase.ModifiedTS.desc()
|
||||||
|
)
|
||||||
|
|
||||||
if limit:
|
if limit:
|
||||||
query = query.limit(limit)
|
query = query.limit(limit)
|
||||||
|
|
||||||
packages = []
|
packages = []
|
||||||
for pkg in query:
|
for pkg in query:
|
||||||
# For each Package returned by the query, append a dict
|
# For each Package returned by the query, append a dict
|
||||||
# containing Package columns we're interested in.
|
# containing Package columns we're interested in.
|
||||||
db.refresh(pkg)
|
|
||||||
packages.append({
|
packages.append({
|
||||||
"Name": pkg.Name,
|
"Name": pkg.Name,
|
||||||
"Version": pkg.Version,
|
"Version": pkg.Version,
|
||||||
|
|
Loading…
Add table
Reference in a new issue