Skip to content

Conversation

@nattsw
Copy link
Contributor

@nattsw nattsw commented Jul 30, 2025

This PR fixes 2 things.

  1. If a post was written in ja (Japanese) and for some reason also had a post_localization that is ja, it becomes 200%
  2. When getting completion progress for "English (US)", if there exists a "English (UK)" localization, we want to include that
  3. Previously the completion count was also getting post_localization from posts that are not candidates. If the user switches ai_translation_backfill_limit_to_public_content from false to true, it would include previously localized PMs when it should not.

Follow up: #33927

@nattsw nattsw changed the title FIX: Completion rate was double-counting FIX: Completion rate double-count and normalize Jul 30, 2025
private

total = get.count
def self.calculate_completion_per_locale(locale)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still a bit of duplication here per-type but we can de-duplicate when we start finalising other models such as tags or localizing tables from other plugins such as post voting comments.

def self.get_completion_per_locale(locale)
Discourse
.cache
.fetch(get_completion_cache_key(locale), expires_in: 1.hour) do
Copy link
Member

Choose a reason for hiding this comment

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

I would push this into a const, its a tough recipe to get right, potentially you want to manually expire the cache on certain events.

overall though ... this is super safe, cause at 1 hour the chances of any excessive work are very low.

@nattsw nattsw merged commit dfd0c52 into main Jul 30, 2025
16 checks passed
@nattsw nattsw deleted the fix-completion-rate branch July 30, 2025 10:09
SamSaffron pushed a commit that referenced this pull request Aug 4, 2025
This PR fixes 2 things. 

1. If a `post` was written in `ja` (Japanese) and for some reason also
had a `post_localization` that is `ja`, it becomes 200%
2. When getting completion progress for "English (US)", if there exists
a "English (UK)" localization, we want to include that
3. Previously the completion count was also getting `post_localization`
from posts that are not candidates. If the user switches
`ai_translation_backfill_limit_to_public_content` from false to true, it
would include previously localized PMs when it should not.

Follow up: #33927
martin-brennan pushed a commit that referenced this pull request Aug 4, 2025
This PR fixes 2 things. 

1. If a `post` was written in `ja` (Japanese) and for some reason also
had a `post_localization` that is `ja`, it becomes 200%
2. When getting completion progress for "English (US)", if there exists
a "English (UK)" localization, we want to include that
3. Previously the completion count was also getting `post_localization`
from posts that are not candidates. If the user switches
`ai_translation_backfill_limit_to_public_content` from false to true, it
would include previously localized PMs when it should not.

Follow up: #33927
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants