Commit 7441fb7f by serpucga

Little bugfix that made single paged collections crash. Also, now code is more elegant

parent a4b15d31
...@@ -4,6 +4,7 @@ import json ...@@ -4,6 +4,7 @@ import json
import re import re
import time import time
import datetime import datetime
import math
import multiprocessing as mp import multiprocessing as mp
from math import ceil from math import ceil
from typing import List, Dict from typing import List, Dict
...@@ -410,11 +411,7 @@ def get_page_index_fast( ...@@ -410,11 +411,7 @@ def get_page_index_fast(
""" """
pages = [] pages = []
first_page = collection.find()\ last_id = math.inf
.sort("id", pymongo.DESCENDING)\
.limit(page_size)
pages.append(first_page[0]["id"])
last_id = first_page[page_size - 1]["id"]
while True: while True:
page = collection.find({"id": {"$lt": last_id}})\ page = collection.find({"id": {"$lt": last_id}})\
.sort("id", pymongo.DESCENDING)\ .sort("id", pymongo.DESCENDING)\
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment