Skip to content

Commit

Permalink
lowercase search languages (#398)
Browse files Browse the repository at this point in the history
convert key and search to lowercase
prevent duplicate insertion

Co-authored-by: Aaron Suarez <aaron-suarez@users.noreply.github.com>
  • Loading branch information
king-11 and Aaron Suarez authored Oct 19, 2020
1 parent f971973 commit 94f7d0a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/api/routes/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ def get_attributes(json):
languages_list = Language.query.all()
categories_list = Category.query.all()

language_dict = {lang.key(): lang for lang in languages_list}
language_dict = {lang.key().lower(): lang for lang in languages_list}
category_dict = {c.key(): c for c in categories_list}

langs = []
for lang in json.get('languages') or []:
language = language_dict.get(lang)
language = language_dict.get(lang.lower())
if not language:
language = Language(name=lang)
langs.append(language)
Expand Down

0 comments on commit 94f7d0a

Please sign in to comment.