Update task iteration when parent iteration gets updated
What does this MR do and why?
This update enhances how iterations work with parent-child work item relationships. The main change allows iteration assignments to cascade from parent work items to their children automatically. When a parent work item's iteration is changed, all child work items that were in the previous iteration will now be updated to match the parent's new iteration.
The code adds tracking for these automated changes by:
- Adding new database columns to record when iteration changes are automated
- Storing which parent work item triggered the change
- Improving the display of these changes in the UI by showing messages like "changed iteration to #123 (closed) on this item and parent item"
The implementation includes database migrations, new scopes to find work items with specific widget types, and callback logic to handle the cascading updates efficiently in batches.
All the changes are under a Feature Flag. The plan is to enable the FF for all gitlab.com
and monitor the performance.
Database
For querying the issues in order to get all the descendants that we need to update, we are using .each_batch
method. The each batch method will run the bellow queries(the limit is the default)
- fetch the 1st ID of the loop
- Localhost: https://explain.depesz.com/s/T3AY
- production: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/37769/commands/115532
- fetch the last ID of the loop
- Localhost: https://explain.depesz.com/s/p5la
- Production: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/37769/commands/115533
- fetch the issues
- Localhost: https://explain.depesz.com/s/LLig (
- Production: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/37769/commands/115526
As we the batch size is 100, we will update the sprint_id for 100 of the descendants, it will execute this query
- Localhost: https://explain.depesz.com/s/p4Uu
- Production: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/37769/commands/115531
And for creating 100 resource_iteration_events, it will execute this query:
- Localhost: https://explain.depesz.com/s/Xygw This can only be tested in localhost as the 2 columns for the resource_iteration_events are added in this MR
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
In order to test it locally. Create a new work item(issue) and create some(1-2) task for the issue. Add an iteration to the issue, the task should also get's an update with the same iteration. The tasks will get updated only when they are open and if the iteration is matching with the issue, including empty iterations.
Note: the tasks will not get updated in the issue show page, you need to open the task in a separate view to see the change and the note.