Skip to content

Commit

Permalink
fix: sort articles in Anki mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Crissium committed Nov 27, 2023
1 parent e0a568c commit a2086c4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/app/dictionaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,12 @@ def extract_article_from_dictionary(dictionary_name: 'str') -> 'None':
article = convert_chinese(article, self.settings.preferences['chinese_preference'])
if dictionary_name in transformation.transform.keys():
article = transformation.transform[dictionary_name](article)
articles.append(article)
articles.append((article, dictionary_name))

with concurrent.futures.ThreadPoolExecutor(len(names_dictionaries_of_group)) as executor:
executor.map(extract_article_from_dictionary, names_dictionaries_of_group)

# Sort the articles by the order of dictionaries in the group (only the articles are preserved)
articles = [article[0] for dictionary_name in names_dictionaries_of_group for article in articles if article[1] == dictionary_name]

return BaseReader._ARTICLE_SEPARATOR.join(articles)

0 comments on commit a2086c4

Please sign in to comment.