Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
migration_scripts
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
serpucga
migration_scripts
Commits
7441fb7f
Commit
7441fb7f
authored
Jul 25, 2019
by
serpucga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Little bugfix that made single paged collections crash. Also, now code is more elegant
parent
a4b15d31
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
5 deletions
+2
-5
utils.py
lib/utils.py
+2
-5
No files found.
lib/utils.py
View file @
7441fb7f
...
@@ -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
)
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment