Skip to content

feat(category): faster removal#18521

Merged
nijel merged 1 commit intoWeblateOrg:mainfrom
nijel:category-removal
Mar 19, 2026
Merged

feat(category): faster removal#18521
nijel merged 1 commit intoWeblateOrg:mainfrom
nijel:category-removal

Conversation

@nijel
Copy link
Member

@nijel nijel commented Mar 18, 2026

Collect components to be removed to better handle situations with many linked components being removed.

@nijel nijel added this to the 5.17 milestone Mar 18, 2026
@nijel nijel requested a review from Copilot March 18, 2026 15:20
@nijel nijel self-assigned this Mar 18, 2026
@nijel nijel requested a review from AliceVisek as a code owner March 18, 2026 15:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the performance of category removal by batching post-delete side effects (stats recalculation and linked-component alert refresh) and by avoiding work for components that are also being removed, which is especially important when a category contains many linked components.

Changes:

  • Introduces RemovalBatch to deduplicate and defer stats updates + linked component update_alerts() until transaction commit.
  • Refactors component/category removal tasks to support batched removals and skip propagation updates for components being removed.
  • Adds regression tests around batching behavior and documents the user-visible improvement in the changelog.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
weblate/trans/tasks.py Refactors removal flow into helper functions and adds batched category removal with deferred flush.
weblate/trans/removal.py Adds RemovalBatch helper to collect and flush deduped updates on commit.
weblate/trans/models/component.py Adds in-memory removal_batch attribute on Component instances used during deletion.
weblate/trans/models/__init__.py Updates component deletion signals to batch stats/linked-alert updates when removal_batch is set.
weblate/trans/tests/test_categories.py Adds tests verifying batching of linked alert refresh, skipping propagation, and batched stats updates.
docs/changes.rst Adds changelog entry for faster category removal.

@nijel nijel force-pushed the category-removal branch from dea3510 to 3532287 Compare March 18, 2026 15:36
@nijel nijel enabled auto-merge (rebase) March 18, 2026 15:37
@nijel nijel force-pushed the category-removal branch 2 times, most recently from 9cec88c to e8d3c3b Compare March 18, 2026 18:44
Collect components to be removed to better handle situations with many
linked components being removed.
@nijel nijel force-pushed the category-removal branch from e8d3c3b to a12b25d Compare March 19, 2026 09:12
@nijel nijel requested a review from Copilot March 19, 2026 09:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the performance of category removal in Weblate by batching follow-up work (stats updates and linked-component alert refreshes) so large removals—especially with many linked components—do not trigger repetitive per-component updates.

Changes:

  • Add RemovalBatch + contextvar plumbing to collect removed component IDs, parent stats objects, and linked-component alert refresh targets.
  • Refactor category_removal (and component removal internals) to use the batch, flush once on transaction commit, and skip propagation work for components that will be removed.
  • Add regression tests validating batching behavior and update/propagation skipping; document the change in the changelog.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
weblate/trans/tasks.py Refactors category removal to pre-collect removal targets and use a single batched flush for stats/alerts, while avoiding propagation scheduling for soon-to-be-removed components.
weblate/trans/removal.py Introduces RemovalBatch and a context manager for batched removal side-effects flushed on commit.
weblate/trans/models/init.py Updates delete signals to use the active removal batch (instance-bound or contextvar) to collect stats and linked alert refreshes instead of scheduling per-delete callbacks.
weblate/trans/models/component.py Adds a non-persistent removal_batch attribute to component instances to associate deletions with a batch.
weblate/trans/tests/test_categories.py Adds tests covering batched alert refresh, propagation skipping, and batched parent stats updates during category removal.
docs/changes.rst Adds a changelog entry for faster category removal.

@nijel nijel merged commit d686da2 into WeblateOrg:main Mar 19, 2026
52 checks passed
@nijel nijel deleted the category-removal branch March 19, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants