mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(packages.search): fix default ordering & improve performance
- Use queries more closely aligned to PHP's implementation; removes the need for separate vote/notification queries. - Default sort by popularity Closes #214 Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
e75aa386ea
commit
56bd60559c
7 changed files with 161 additions and 90 deletions
|
@ -816,6 +816,33 @@ def test_packages_search_by_submitter(client: TestClient,
|
|||
assert len(rows) == 1
|
||||
|
||||
|
||||
def test_packages_sort_by_name(client: TestClient, packages: List[Package]):
|
||||
with client as request:
|
||||
response = request.get("/packages", params={
|
||||
"SB": "n", # Name
|
||||
"SO": "a", # Ascending
|
||||
"PP": "150"
|
||||
})
|
||||
assert response.status_code == int(HTTPStatus.OK)
|
||||
|
||||
root = parse_root(response.text)
|
||||
rows = root.xpath('//table[@class="results"]/tbody/tr')
|
||||
rows = [row.xpath('./td/a')[0].text.strip() for row in rows]
|
||||
|
||||
with client as request:
|
||||
response2 = request.get("/packages", params={
|
||||
"SB": "n", # Name
|
||||
"SO": "d", # Ascending
|
||||
"PP": "150"
|
||||
})
|
||||
assert response2.status_code == int(HTTPStatus.OK)
|
||||
|
||||
root = parse_root(response2.text)
|
||||
rows2 = root.xpath('//table[@class="results"]/tbody/tr')
|
||||
rows2 = [row.xpath('./td/a')[0].text.strip() for row in rows2]
|
||||
assert rows == list(reversed(rows2))
|
||||
|
||||
|
||||
def test_packages_sort_by_votes(client: TestClient,
|
||||
maintainer: User,
|
||||
packages: List[Package]):
|
||||
|
|
|
@ -656,6 +656,9 @@ def test_rpc_msearch(client: TestClient, user: User, packages: List[Package]):
|
|||
data = response.json()
|
||||
assert data.get("resultcount") == 0
|
||||
|
||||
with db.begin():
|
||||
packages[0].PackageBase.Maintainer = None
|
||||
|
||||
# A missing arg still succeeds, but it returns all orphans.
|
||||
# Just verify that we receive no error and the orphaned result.
|
||||
params.pop("arg")
|
||||
|
@ -663,7 +666,7 @@ def test_rpc_msearch(client: TestClient, user: User, packages: List[Package]):
|
|||
data = response.json()
|
||||
assert data.get("resultcount") == 1
|
||||
result = data.get("results")[0]
|
||||
assert result.get("Name") == "woogly-chungus"
|
||||
assert result.get("Name") == "big-chungus"
|
||||
|
||||
|
||||
def test_rpc_search_depends(client: TestClient, packages: List[Package],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue