Verified Commit 89f081a8 authored by Kevin Morris's avatar Kevin Morris
Browse files

Merge branch 'master' into live

parents 87b94ce0 0afa07ed
Pipeline #16423 passed with stages
in 4 minutes and 15 seconds
...@@ -6,7 +6,7 @@ from typing import Any ...@@ -6,7 +6,7 @@ from typing import Any
# Publicly visible version of aurweb. This is used to display # Publicly visible version of aurweb. This is used to display
# aurweb versioning in the footer and must be maintained. # aurweb versioning in the footer and must be maintained.
# Todo: Make this dynamic/automated. # Todo: Make this dynamic/automated.
AURWEB_VERSION = "v6.0.23" AURWEB_VERSION = "v6.0.24"
_parser = None _parser = None
......
...@@ -332,7 +332,7 @@ class RPC: ...@@ -332,7 +332,7 @@ class RPC:
models.PackageBase models.PackageBase
).filter( ).filter(
and_(models.PackageBase.PackagerUID.isnot(None), and_(models.PackageBase.PackagerUID.isnot(None),
models.Package.Name.like(f"%{arg}%")) models.Package.Name.like(f"{arg}%"))
).order_by(models.Package.Name.asc()).limit(20) ).order_by(models.Package.Name.asc()).limit(20)
return [pkg.Name for pkg in packages] return [pkg.Name for pkg in packages]
...@@ -341,9 +341,10 @@ class RPC: ...@@ -341,9 +341,10 @@ class RPC:
if not args: if not args:
return [] return []
arg = args[0]
packages = db.query(models.PackageBase.Name).filter( packages = db.query(models.PackageBase.Name).filter(
and_(models.PackageBase.PackagerUID.isnot(None), and_(models.PackageBase.PackagerUID.isnot(None),
models.PackageBase.Name.like(f"%{args[0]}%")) models.PackageBase.Name.like(f"{arg}%"))
).order_by(models.PackageBase.Name.asc()).limit(20) ).order_by(models.PackageBase.Name.asc()).limit(20)
return [pkg.Name for pkg in packages] return [pkg.Name for pkg in packages]
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# #
[tool.poetry] [tool.poetry]
name = "aurweb" name = "aurweb"
version = "v6.0.23" version = "v6.0.24"
license = "GPL-2.0-only" license = "GPL-2.0-only"
description = "Source code for the Arch User Repository's website" description = "Source code for the Arch User Repository's website"
homepage = "https://aur.archlinux.org" homepage = "https://aur.archlinux.org"
......
...@@ -551,6 +551,14 @@ def test_rpc_suggest_pkgbase(client: TestClient, packages: List[Package]): ...@@ -551,6 +551,14 @@ def test_rpc_suggest_pkgbase(client: TestClient, packages: List[Package]):
data = response.json() data = response.json()
assert data == [] assert data == []
# Test that suggestions are only given based on the beginning
# of the keyword string.
params["arg"] = "ther-pkg"
with client as request:
response = request.get("/rpc", params=params)
data = response.json()
assert data == []
def test_rpc_suggest(client: TestClient, packages: List[Package]): def test_rpc_suggest(client: TestClient, packages: List[Package]):
params = {"v": 5, "type": "suggest", "arg": "other"} params = {"v": 5, "type": "suggest", "arg": "other"}
...@@ -573,6 +581,14 @@ def test_rpc_suggest(client: TestClient, packages: List[Package]): ...@@ -573,6 +581,14 @@ def test_rpc_suggest(client: TestClient, packages: List[Package]):
data = response.json() data = response.json()
assert data == [] assert data == []
# Test that suggestions are only given based on the beginning
# of the keyword string.
params["arg"] = "ther-pkg"
with client as request:
response = request.get("/rpc", params=params)
data = response.json()
assert data == []
def mock_config_getint(section: str, key: str): def mock_config_getint(section: str, key: str):
if key == "request_limit": if key == "request_limit":
......
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