Skip to content

Commit

Permalink
fix(component): reset last change cache when creating new translation
Browse files Browse the repository at this point in the history
This avoids expensive last change lookup while creating new translations
(both directly or via glossary sync).
  • Loading branch information
nijel committed Feb 13, 2025
1 parent cdb88b2 commit fae525d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions weblate/trans/models/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -3650,14 +3650,18 @@ def add_new_language(
self.commit_pending("add language", None)

# Create or get translation object
translation = self.translation_set.get_or_create(
translation, created = self.translation_set.get_or_create(
language=language,
defaults={
"plural": language.plural,
"filename": filename,
"language_code": code,
},
)[0]
)
# Make it clear that there is no change for the newly created translation
# to avoid expensive last change lookup in stats while committing changes.
if created:
Change.store_last_change(translation, None)

# Create the file
if os.path.exists(fullname):
Expand Down

0 comments on commit fae525d

Please sign in to comment.