Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
osqa-to-askbot
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gruppo Ask
osqa-to-askbot
Commits
36cb8fc9
Commit
36cb8fc9
authored
Dec 20, 2016
by
Pietro Albini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some users not properly migrated to Askbot
parent
700f92de
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
osqa_migrator/migrator.py
osqa_migrator/migrator.py
+3
-3
osqa_migrator/utils.py
osqa_migrator/utils.py
+8
-3
No files found.
osqa_migrator/migrator.py
View file @
36cb8fc9
...
@@ -69,7 +69,7 @@ class Migrator:
...
@@ -69,7 +69,7 @@ class Migrator:
last_id
=
0
last_id
=
0
tbl
=
"auth_user a, forum_user f WHERE a.id = f.user_ptr_id"
tbl
=
"auth_user a, forum_user f WHERE a.id = f.user_ptr_id"
for
user
in
self
.
osqa
.
table_items
(
tbl
,
what
=
"users"
):
for
user
in
self
.
osqa
.
table_items
(
tbl
,
what
=
"users"
,
order
=
"id"
):
last_id
=
user
[
"id"
]
last_id
=
user
[
"id"
]
# Check if the user already exists
# Check if the user already exists
...
@@ -112,8 +112,8 @@ class Migrator:
...
@@ -112,8 +112,8 @@ class Migrator:
)]
)]
last_id
=
0
last_id
=
0
t
able
=
"forum_authkeyuserassociation"
t
=
"forum_authkeyuserassociation"
for
login
in
self
.
osqa
.
table_items
(
t
able
,
what
=
"user logins
"
):
for
login
in
self
.
osqa
.
table_items
(
t
,
what
=
"user logins"
,
order
=
"id
"
):
last_id
=
login
[
"id"
]
last_id
=
login
[
"id"
]
# Check if the login entry already exists
# Check if the login entry already exists
...
...
osqa_migrator/utils.py
View file @
36cb8fc9
...
@@ -73,12 +73,17 @@ class Connection:
...
@@ -73,12 +73,17 @@ class Connection:
cursor
.
execute
(
query
,
params
)
cursor
.
execute
(
query
,
params
)
return
cursor
.
fetchall
()
return
cursor
.
fetchall
()
def
table_items
(
self
,
name
,
batch
=
100
,
what
=
None
):
def
table_items
(
self
,
name
,
batch
=
100
,
what
=
None
,
order
=
None
):
"""Return items in a table without loading all of them in memory"""
"""Return items in a table without loading all of them in memory"""
# This loads elements in batches, to avoid loading too much stuff in
# This loads elements in batches, to avoid loading too much stuff in
# memory and going OOM
# memory and going OOM
total
=
self
.
query
(
"SELECT COUNT(*) FROM %s;"
%
name
)[
0
][
0
]
total
=
self
.
query
(
"SELECT COUNT(*) FROM %s;"
%
name
)[
0
][
0
]
if
order
is
not
None
:
order
=
"ORDER BY %s"
%
order
else
:
order
=
""
pb
=
None
pb
=
None
if
what
is
not
None
:
if
what
is
not
None
:
pb
=
ProgressBar
(
"Migrating %s"
%
what
,
what
,
total
)
pb
=
ProgressBar
(
"Migrating %s"
%
what
,
what
,
total
)
...
@@ -90,8 +95,8 @@ class Connection:
...
@@ -90,8 +95,8 @@ class Connection:
for
i
in
range
(
steps
):
for
i
in
range
(
steps
):
query
=
(
query
=
(
"SELECT * FROM %s LIMIT %s OFFSET %s;"
%
"SELECT * FROM %s
%s
LIMIT %s OFFSET %s;"
%
(
name
,
batch
,
i
*
batch
)
(
name
,
order
,
batch
,
i
*
batch
)
)
)
for
(
i2
,
item
)
in
enumerate
(
self
.
query
(
query
)):
for
(
i2
,
item
)
in
enumerate
(
self
.
query
(
query
)):
if
pb
is
not
None
:
if
pb
is
not
None
:
...
...
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