Commit 700f92de authored by Pietro Albini's avatar Pietro Albini

Speed up skipping existing data

parent 61c317ea
......@@ -62,17 +62,19 @@ class Migrator:
"location", "last_seen",
]
# Load existing users
existing = [u[0] for u in self.askbot_query(
"SELECT id FROM auth_user;"
)]
last_id = 0
tbl = "auth_user a, forum_user f WHERE a.id = f.user_ptr_id"
for user in self.osqa.table_items(tbl, what="users"):
last_id = user["id"]
# Check if the user already exists
try:
self.models.User.objects.get(id=user["id"])
if user["id"] in existing:
continue
except self.models.User.DoesNotExist:
pass
# Create a new User object
new = self.models.User()
......@@ -104,17 +106,19 @@ class Migrator:
def migrate_user_logins(self):
"""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
table = "forum_authkeyuserassociation"
for login in self.osqa.table_items(table, what="user logins"):
last_id = login["id"]
# Check if the association already exists
try:
self.openid_models.UserAssociation.objects.get(id=login["id"])
# Check if the login entry already exists
if login["id"] in existing:
continue
except self.openid_models.UserAssociation.DoesNotExist:
pass
# Migrate login data
assoc = self.openid_models.UserAssociation()
......
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