Skip to content

Schedule iterations on cadence start weekday

euko requested to merge 354977-schedule-on-the-same-weekday into master

What does this MR do and why?

Completes backend for #354977 (closed)

This MR implements the following requirements outlined in #354977 (closed):

  • Iterations should be scheduled on the weekday derived from the cadence start date.
  • When the start date of a cadence changes - only possible if it has not already started - the dates of all existing upcoming iterations need to be re-aligned.

Example 1.

#354977 (comment 904436779)

  1. If I create a cadence with a start date of Jun 6
  2. It is May 1 and I update the cadence to start the cadence on May 1
  3. The two iterations in June would have their dates changed to May 2-8 and May 9-15 respectively

Example 2. An automatic cadence starts on Thu May 5. The cadence then should schedule iterations to start on Thursdays.

Example 3. The first iteration in a manual cadence started on Wednesday. When it's converted to use automated scheduling, all iterations created after the conversion need to be scheduled on Wednesday.

How to set up and validate locally

The specs have been refactored to closely follow typical user interactions. It may be helpful to reference them.

  1. Enable Iterations Cadence in the Rails console
Feature.enable(:iteration_cadences)
  1. Create a new group (not strictly necessary but recommended to avoid confusion.)

  2. Visit Iterations page and create a new cadence. Set the start date to a future date.

  3. After iterations are initially scheduled, adjust the cadence's start date again to another future date.

    Check that existing iterations are correctly adjusted with the first iteration starting on the new start date of the cadence.

  4. Edit the start date of the cadence again. Set the start date to the current date or some date in the past.

    Check that existing iterations are correctly adjusted.

Try various scenarios like modifying the duration of a cadence.

demo

demo

Test with a manual cadence

  1. In the Rails console, enter the following line - just substitute the group - to create a manual cadence (this is faster and less onerous than turning off the feature flag and on again.)
group = Group.find(126)
Iterations::Cadence.new(group: group, start_date: Date.new(2022, 4, 4), last_run_date: nil, duration_in_weeks: 2, iterations_in_advance: 2, active: true, automatic: false, title: "manual cadence", roll_over: false).save!(validate: false)
  1. Create some iterations then convert the manual cadence to use automated scheduling.

  2. Check that existing past and current iterations stay intact but upcoming iterations are scheduled/adjusted correctly

demo

demo2

Edited by euko

Merge request reports