perf: improve packages search-query

Improves performance for queries with large result sets.

The "group by" clause can be removed for all search types but the keywords.

Signed-off-by: moson-mo <mo-son@mailbox.org>
This commit is contained in:
moson-mo 2022-11-29 14:45:24 +01:00
parent d8e91d058c
commit 7a9448a3e5
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
3 changed files with 33 additions and 17 deletions

View file

@ -740,6 +740,23 @@ def test_packages_search_by_keywords(client: TestClient, packages: list[Package]
rows = root.xpath('//table[@class="results"]/tbody/tr')
assert len(rows) == 1
# Now let's add another keyword to the same package
with db.begin():
db.create(
PackageKeyword, PackageBase=package.PackageBase, Keyword="testKeyword2"
)
# And request packages with both keywords, we should still get 1 result.
with client as request:
response = request.get(
"/packages", params={"SeB": "k", "K": "testKeyword testKeyword2"}
)
assert response.status_code == int(HTTPStatus.OK)
root = parse_root(response.text)
rows = root.xpath('//table[@class="results"]/tbody/tr')
assert len(rows) == 1
def test_packages_search_by_maintainer(
client: TestClient, maintainer: User, package: Package