Fix API packages with no arguments

This commit is contained in:
rubenwardy 2021-01-30 19:49:15 +00:00
parent c0112828eb
commit 912b917a47
2 changed files with 4 additions and 4 deletions

@ -404,10 +404,10 @@ class Package(db.Model):
"type": self.type.toName(),
}
def getAsDictionaryShort(self, base_url, version=None, release_id=None):
def getAsDictionaryShort(self, base_url, version=None, release_id=None, no_load=False):
tnurl = self.getThumbnailURL(1)
if release_id is None:
if release_id is None and no_load == False:
release = self.getDownloadRelease(version=version)
release_id = release and release.id

@ -89,8 +89,8 @@ class QueryBuilder:
releases[package_id] = release_id
def toJson(package: Package):
release_id = releases[package.id]
return package.getAsDictionaryShort(current_app.config["BASE_URL"], release_id=release_id)
release_id = releases.get(package.id)
return package.getAsDictionaryShort(current_app.config["BASE_URL"], release_id=release_id, no_load=True)
return [toJson(pkg) for pkg in packages]