Skip to content

Commit

Permalink
tweak page snapshot sort order
Browse files Browse the repository at this point in the history
  • Loading branch information
ikreymer committed Feb 20, 2025
1 parent 85d4c6f commit bf6f24b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions backend/btrixcloud/colls.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,13 +794,12 @@ async def list_page_snapshots_in_collection(
crawl_ids = await self.get_collection_crawl_ids(coll_id)

match_query: dict[str, object] = {"crawl_id": {"$in": crawl_ids}}
sort_query: dict[str, int] = {"isSeed": -1, "url": 1, "ts": 1}
sort_query: dict[str, int] = {"isSeed": -1, "ts": 1, "url": 1}

if url_prefix:
url_prefix = urllib.parse.unquote(url_prefix)
regex_pattern = f"^{re.escape(url_prefix)}"
match_query["url"] = {"$regex": regex_pattern, "$options": "i"}
# sort_query = {"ts": 1}

aggregate: List[Dict[str, Union[int, object]]] = [
{"$match": match_query},
Expand Down
2 changes: 1 addition & 1 deletion backend/btrixcloud/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ async def init_index(self):
[
("crawl_id", pymongo.HASHED),
("isSeed", pymongo.DESCENDING),
("url", pymongo.ASCENDING),
("ts", pymongo.ASCENDING),
("url", pymongo.ASCENDING),
]
)
await self.pages.create_index(
Expand Down

0 comments on commit bf6f24b

Please sign in to comment.