Skip to content

Trigger epic dates update when adding or removing a child epic

Eugenia Grieff requested to merge 459990-fix-epics-inherited-dates into master

What does this MR do and why?

Related to #459990 (closed)

When changing an epic's hierarchy we need to call Epics::UpdateDatesService to recalculate the epic's date. This call is currently missing when adding or removing a single child epic (it only works when adding multiple child epics) so this MR fixes that.

Also, this MR adds a condition in the places where we're calling this service, to skip the call if the epic is being synced because in that case the dates are updates along the work item in WorkItems::Widgets::RolledupDatesService::HierarchyUpdateService

Summary of changes:

  • Refactor the Epics::UpdateDatesService call in EE:IssuableLinks::CreateService to move the condition to a separate method skip_epic_dates_update?.
  • Override this new method in EpicIssues::CreateService and EpicLinks::CreateService to not call the dates service if the epic is being synced to the work item (and work_items_rolledup_dates FF is enabled - context: !151751 (comment 1900410272))
  • Update EpicLinks::CreateService to also update the epic dates when a single child epic is added. This was missing because the method that calls this service link_issuables is not used when linking a single child. For this case, the dates service is called from update_inherited_dates, which contains the abovementioned condition.
  • Update EpicLinks::DestroyService to call Epics::UpdateDatesService when a child is removed. This was missing for child epics but already implemented for child issues in EpicIssues::DestroyService#after_destroy and the condition to skip the call when syncing was added in !151356 (merged)

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.

Screenshots

Screen_Recording_2024-05-07_at_15.39.24

How to set up and validate locally

  1. Create an epic Parent Epic and update its dates to inherited
  2. Create an additional epic Child Epic [May] and change its dates to fixed setting start date as May 1st and the end date as May 31st.
  3. Add this epic as a child of Parent Epic and verify that the parent dates are set to May (requires reloading the page)
  4. Finally, remove the child and verify that the parent's dates are updated to None.

To verify that Epics::UpdateDatesService is skipped when syncing the epic, visit the work item view http://gdk.test:3000/groups/GROUP_PATH/-/work_items/PARENT_EPIC_IID and repeat the same steps but this time check that WorkItems::RolledupDates::UpdateRolledupDatesWorker is called instead.

Edited by Kassio Borges

Merge request reports