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
700f92de
Commit
700f92de
authored
Dec 20, 2016
by
Pietro Albini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up skipping existing data
parent
61c317ea
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
osqa_migrator/migrator.py
osqa_migrator/migrator.py
+13
-9
No files found.
osqa_migrator/migrator.py
View file @
700f92de
...
@@ -62,17 +62,19 @@ class Migrator:
...
@@ -62,17 +62,19 @@ class Migrator:
"location"
,
"last_seen"
,
"location"
,
"last_seen"
,
]
]
# Load existing users
existing
=
[
u
[
0
]
for
u
in
self
.
askbot_query
(
"SELECT id FROM auth_user;"
)]
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"
):
last_id
=
user
[
"id"
]
last_id
=
user
[
"id"
]
# Check if the user already exists
# Check if the user already exists
try
:
if
user
[
"id"
]
in
existing
:
self
.
models
.
User
.
objects
.
get
(
id
=
user
[
"id"
])
continue
continue
except
self
.
models
.
User
.
DoesNotExist
:
pass
# Create a new User object
# Create a new User object
new
=
self
.
models
.
User
()
new
=
self
.
models
.
User
()
...
@@ -104,17 +106,19 @@ class Migrator:
...
@@ -104,17 +106,19 @@ class Migrator:
def
migrate_user_logins
(
self
):
def
migrate_user_logins
(
self
):
"""Migrate the login table"""
"""Migrate the login table"""
# Load existing users
existing
=
[
u
[
0
]
for
u
in
self
.
askbot_query
(
"SELECT id FROM django_authopenid_userassociation;"
)]
last_id
=
0
last_id
=
0
table
=
"forum_authkeyuserassociation"
table
=
"forum_authkeyuserassociation"
for
login
in
self
.
osqa
.
table_items
(
table
,
what
=
"user logins"
):
for
login
in
self
.
osqa
.
table_items
(
table
,
what
=
"user logins"
):
last_id
=
login
[
"id"
]
last_id
=
login
[
"id"
]
# Check if the association already exists
# Check if the login entry already exists
try
:
if
login
[
"id"
]
in
existing
:
self
.
openid_models
.
UserAssociation
.
objects
.
get
(
id
=
login
[
"id"
])
continue
continue
except
self
.
openid_models
.
UserAssociation
.
DoesNotExist
:
pass
# Migrate login data
# Migrate login data
assoc
=
self
.
openid_models
.
UserAssociation
()
assoc
=
self
.
openid_models
.
UserAssociation
()
...
...
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