Skip to content

Commit

Permalink
Fix test and ensure depth: 0 only returns int results
Browse files Browse the repository at this point in the history
  • Loading branch information
tw4l committed Feb 6, 2025
1 parent a7a7988 commit d3fcab8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions backend/btrixcloud/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,10 @@ async def list_pages(
if is_seed in (True, False):
query["isSeed"] = is_seed

# Check that field matches and value is an int to avoid 0
# from returning null results
if depth:
query["depth"] = depth
query["$and"] = {"field": depth, "type": 16}

if reviewed:
query["$or"] = [
Expand Down Expand Up @@ -697,8 +699,10 @@ async def list_collection_pages(
if is_seed in (True, False):
query["isSeed"] = is_seed

# Check that field matches and value is an int to avoid 0
# from returning null results
if depth:
query["depth"] = depth
query["$and"] = {"field": depth, "type": 16}

aggregate = [{"$match": query}]

Expand Down
4 changes: 2 additions & 2 deletions backend/test/test_run_crawl.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,13 +872,13 @@ def test_crawl_pages_qa_filters(crawler_auth_headers, default_org_id, crawler_cr
assert r.status_code == 200
assert r.json()["total"] == 2

# Test reviewed filter (page now approved so should show up in True)
# Test reviewed filter (page now approved so should show up in True, other pages show here)
r = requests.get(
f"{API_PREFIX}/orgs/{default_org_id}/crawls/{crawler_crawl_id}/pages?reviewed=False",
headers=crawler_auth_headers,
)
assert r.status_code == 200
assert r.json()["total"] == 0
assert r.json()["total"] == 2

r = requests.get(
f"{API_PREFIX}/orgs/{default_org_id}/crawls/{crawler_crawl_id}/pages?reviewed=True",
Expand Down

0 comments on commit d3fcab8

Please sign in to comment.