Skip to content

Commit

Permalink
More load_flashcards speed-up
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Oct 29, 2016
1 parent 4df41fb commit 714ddb3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions proso_flashcards/management/commands/load_flashcards.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _load_categories(self, data=None):
for category in progress.bar(data, every=max(1, len(data) // 100)):
langs = [k[-2:] for k in category.keys() if re.match(r'^name-\w\w$', k)]
for lang in langs:
db_category = Category.objects.filter(identifier=category["id"], lang=lang).first()
db_category = db_categories.get((category["id"], lang))
if db_category is None:
db_category = Category(
identifier=category["id"],
Expand Down Expand Up @@ -107,7 +107,7 @@ def _load_contexts(self, data=None):
for context in progress.bar(data, every=max(1, len(data) // 100)):
langs = [k[-2:] for k in list(context.keys()) if re.match(r'^name-\w\w$', k)]
for lang in langs:
db_context = model.objects.filter(identifier=context["id"], lang=lang).first()
db_context = self.db_contexts.get((context["id"], lang))
if db_context is None:
db_context = model(
identifier=context["id"],
Expand Down

0 comments on commit 714ddb3

Please sign in to comment.