Verified Commit b7475a5b authored by Kevin Morris's avatar Kevin Morris
Browse files

fix(rpc): fix performance of suggest[-pkgbase]



We were selecting the entire record; we should just select
the Name column as done in this commit.

Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent 61f3cb93
Pipeline #12760 passed with stages
in 13 minutes and 45 seconds
......@@ -213,7 +213,9 @@ class RPC:
return []
arg = args[0]
packages = db.query(models.Package).join(models.PackageBase).filter(
packages = db.query(models.Package.Name).join(
models.PackageBase
).filter(
and_(models.PackageBase.PackagerUID.isnot(None),
models.Package.Name.like(f"%{arg}%"))
).order_by(models.Package.Name.asc()).limit(20)
......@@ -223,11 +225,11 @@ class RPC:
if not args:
return []
records = db.query(models.PackageBase).filter(
packages = db.query(models.PackageBase.Name).filter(
and_(models.PackageBase.PackagerUID.isnot(None),
models.PackageBase.Name.like(f"%{args[0]}%"))
).order_by(models.PackageBase.Name.asc()).limit(20)
return [record.Name for record in records]
return [pkg.Name for pkg in packages]
def handle(self, by: str = defaults.RPC_SEARCH_BY, args: List[str] = []):
""" Request entrypoint. A router should pass v, type and args
......
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