Skip to content

Commit

Permalink
Ensure /all-crawls?sortBy=qaState always sorts crawls above uploads (#…
Browse files Browse the repository at this point in the history
…1691)

Follow-up to #1686
  • Loading branch information
tw4l authored Apr 18, 2024
1 parent 9f0a1fc commit b87860c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion backend/btrixcloud/basecrawls.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,9 +627,11 @@ async def list_all_base_crawls(

sort_query = {sort_by: sort_direction}

# Add secondary sort for qaState - sorted by current, then last
# Secondary sort for qaState - sorted by current, then last
# Tertiary sort for qaState - type, always ascending so crawls are first
if sort_by == "qaState":
sort_query["lastQAState"] = sort_direction
sort_query["type"] = 1

aggregate.extend([{"$sort": sort_query}])

Expand Down
14 changes: 14 additions & 0 deletions backend/test/test_uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,20 @@ def test_list_all_crawls(
assert item["finished"]
assert item["state"]

# Test that all-crawls qaState sort always puts crawls before uploads
r = requests.get(
f"{API_PREFIX}/orgs/{default_org_id}/all-crawls?sortBy=qaState",
headers=admin_auth_headers,
)
assert r.status_code == 200
data = r.json()

last_type = None
for item in data["items"]:
if last_type == "upload":
assert item["type"] != "crawl"
last_type = item["type"]


def test_get_all_crawls_by_name(
admin_auth_headers, default_org_id, replaced_upload_id, upload_id_2
Expand Down

0 comments on commit b87860c

Please sign in to comment.