Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rotation advancing on user remove #3771

Open
Forfold opened this issue Mar 25, 2024 · 2 comments
Open

rotation advancing on user remove #3771

Forfold opened this issue Mar 25, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Forfold
Copy link
Contributor

Forfold commented Mar 25, 2024

Describe the Bug:
When removing a user from a rotation, the list of users and who is active gets shifted unexpectedly. As a user, I would expect the current on-call person to stay on call.

Steps to Reproduce:

  1. Go to a rotation with a few users
  2. Click on 'Remove user' on someone before the active user
  3. Confirm, and notice the active user shift

Expected Behavior:

  • Active user does not shift when removing a rotation participant
@Forfold Forfold added the bug Something isn't working label Mar 25, 2024
@mastercactapus
Copy link
Member

I feel like we've had and fixed this bug before; fixing this should include a test for the regression

@Forfold
Copy link
Contributor Author

Forfold commented Jul 29, 2024

Failing inside of updateRotationParticipants when calling updateRotation with a list of userIDs to remove:

	if len(userIDs) == 0 {
		// Delete rotation state if all users are going to be deleted as per new input
		err = m.RotationStore.DeleteStateTx(ctx, tx, rotationID)
		if err != nil {
			return err
		}
	} else if updateActive {
		// get current active participant
		s, err := m.RotationStore.StateTx(ctx, tx, rotationID)
		if errors.Is(err, rotation.ErrNoState) {
			return nil
		}
		if err != nil {
			return err
		}

		// if currently active user is going to be deleted
		// then set to first user before we actually delete any users
		if s.Position >= len(userIDs) {
			err = m.RotationStore.SetActiveIndexTx(ctx, tx, rotationID, 0)
			if err != nil {
				return err
			}
		}
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants