Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement automated cleanup of unused glossary languages #11189

Closed
wants to merge 2 commits into from

Conversation

AmanSal1
Copy link

@AmanSal1 AmanSal1 commented Mar 13, 2024

Proposed changes

This commit implements a solution to identify and remove unnecessary empty glossary languages in the translation tool. It calculates a set of empty glossary languages by comparing the set of all glossary languages associated with a component to the set of languages with non-empty glossary entries in its translations. The identified empty glossary languages are then removed from the component.

Additionally, this commit addresses the removal of translation languages and their associated glossary languages. It identifies removed translation languages and iterates through their associated glossary languages, removing them from the component.

These changes streamline the management of glossary languages and ensure that only relevant languages are retained in the system.

Checklist

  • Lint and unit tests pass locally with my changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added documentation to describe my feature.
  • I have squashed my commits into logic units.
  • I have described the changes in the commit messages.

Other information

Fixes: #11168

Copy link
Member

@nijel nijel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please also add a test case to verify your fix is effective?

@@ -28,6 +28,29 @@ def sync_glossary_languages(pk: int, component: Component | None = None):
)
if not missing:
return

# Identify unnecessary empty glossary languages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be executed only in case some languages are missing, see the above condition.

@@ -28,6 +28,29 @@ def sync_glossary_languages(pk: int, component: Component | None = None):
)
if not missing:
return

# Identify unnecessary empty glossary languages
empty_glossary_languages = set(component.glossary_languages.all()) - set(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AttributeError: 'Component' object has no attribute 'glossary_languages'.


# Identify unnecessary empty glossary languages
empty_glossary_languages = set(component.glossary_languages.all()) - set(
component.translations.filter(glossary_entries__isnull=False).values_list(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no such field glossary_entries.

Copy link

This pull request has been automatically marked as stale because there wasn’t any recent activity.

It will be closed soon if no further action occurs.

Thank you for your contributions!

@github-actions github-actions bot added the wontfix Nobody will work on this. label Apr 21, 2024
@github-actions github-actions bot closed this May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix Nobody will work on this.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove empty stale glossaries
2 participants