feat(unit): apply delta of stats upon edit#18588
Open
nijel wants to merge 1 commit intoWeblateOrg:mainfrom
Open
feat(unit): apply delta of stats upon edit#18588nijel wants to merge 1 commit intoWeblateOrg:mainfrom
nijel wants to merge 1 commit intoWeblateOrg:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an incremental (“delta”) update path for translation/component statistics when editing template/source units, aiming to avoid expensive full stats rebuilds on large components while still falling back to full recomputation when the delta can’t be trusted.
Changes:
- Add unit “snapshot” + bucketing utilities in
TranslationStatsto compute per-unit stat deltas. - Update
Unit.update_source_units()to apply deltas on commit (or fall back toComponent.invalidate_cache()when needed) and add a cache-invalidation suppression mechanism onTranslation. - Add/adjust tests around stats invalidation behavior for source edits and AUTO translations.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
weblate/utils/stats.py |
Adds UnitSnapshot and delta/bucket helpers plus apply_source_delta() on TranslationStats. |
weblate/trans/models/unit.py |
Refactors template source propagation to attempt delta-based stats updates; marks cases requiring full rebuild; minor cleanup. |
weblate/trans/models/translation.py |
Adds suppress_cache_invalidation() and a flag to force full stats rebuild fallback. |
weblate/trans/tests/test_edit.py |
Adds tests asserting cache invalidation behavior for source edits and AUTO translations. |
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This avoids possibly expensive full stats update on large components and only applies delta that can be inferred from the current edit. The scope of delta handling is intentionally narrow to handle only the simple cases and avoid code complexity. If delta approach cannot be used, it falls back to standard stats calculation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This avoids possibly expensive full stats update on large components and only applies delta that can be inferred from the current edit. The scope of delta handling is intentionally narrow to handle only the simple cases and avoid code complexity. If delta approach cannot be used, it falls back to standard stats calculation.