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

Volunteer shown as actively assigned to two supervisors after being re-assigned #797

Closed
cliftonmcintosh opened this issue Sep 19, 2020 · 8 comments · Fixed by #839
Closed

Comments

@cliftonmcintosh
Copy link
Collaborator

Expected Behavior

When a volunteer has been unassigned from a supervisor, that volunteer's listing with that supervisor should have the text "Unassigned" in the "Assign" column even after that volunteer has been assigned to a new supervisor.

Actual Behavior

When a volunteer has been unassigned from a supervisor and then the volunteer has been assigned to a new supervisor, the list of volunteers for the old supervisor has the "Unassign" button visible for the volunteer.

Steps to reproduce

  • Assign a volunteer to one supervisor.
  • Unassign that volunteer from that supervisor.
  • Assign the volunteer to a different supervisor.
  • Visit both supervisors' edit pages and note that the "Unassign" button is now visible for that volunteer on both views even though the volunteer is only actively assigned to one of them.

Screenshots and data

In this example, Lincoln Huels was unassigned from Craig Blick and then assigned to Mrs. Jarrett Dicki. Note the "is_active" flag for Lincoln's records. However, Lincoln no longer has the "Unassigned" text in the listing of Craig Blick's volunteers.

Database records

casa_development=# select sv.id, v.display_name as "volunteer", s.display_name as "supervisor", s.id as "supervisor id", sv.is_active
casa_development-# from users v
casa_development-# join supervisor_volunteers sv
casa_development-# on v.id = sv.volunteer_id
casa_development-# join users s
casa_development-# on s.id = sv.supervisor_id
casa_development-# order by s.id, v.display_name;
 id |    volunteer     |     supervisor     | supervisor id | is_active 
----+------------------+--------------------+---------------+-----------
  2 | Lincoln Huels    | Mrs. Jarrett Dicki |           101 | t
  1 | Steven Ebert     | Mrs. Jarrett Dicki |           101 | t
  3 | Lincoln Huels    | Craig Blick        |           102 | f
  5 | Nelly Schuppe II | Craig Blick        |           102 | t
(4 rows)

sv-db-records

Mrs. Jarrett Dicki (supervisor 101), the volunteer's current supervisor, correctly has the "Unassign" button visible for Lincoln Huels
supervisor-101-correctly-active

Craig Blick (supervisor 102), the volunteer's previous supervisor, incorrectly has the "Unassign" button visible for Lincoln Huels
supervisor-102-incorrectly-active-volunteer

@cliftonmcintosh cliftonmcintosh added this to To do in CASA Volunteer Portal via automation Sep 19, 2020
@cliftonmcintosh
Copy link
Collaborator Author

I believe this was introduced with #765

@compwron
Copy link
Collaborator

Oh noooo not again
Thank you for the github issue. This definitely needs fixing

@Zrrrpy Zrrrpy added ⚡ Power ⚡ Help Wanted This is a special label that enables github to showcase issues that want help Priority: High Type: Bug labels Sep 20, 2020
@Zrrrpy
Copy link
Collaborator

Zrrrpy commented Sep 20, 2020

@cliftonmcintosh just wanted to express my gratitude for all the detail you provided in this issue – I didn't need to add anything! Thank you for making this clear and easy for a contributor to pick up.

@drborges
Copy link
Collaborator

I'll give this one a try. Perfect PR description 👌🏼

@drborges drborges self-assigned this Sep 22, 2020
@drborges drborges moved this from To do to In progress in CASA Volunteer Portal Sep 22, 2020
@cliftonmcintosh
Copy link
Collaborator Author

@drborges

One thing to note is that the volunteers to supervisors relationship is many to one right now. It seems to me that if there are two records for a volunteer in the supervisor_volunteers table, one which connects the volunteer to an old supervisor and another which connects the volunteer to a new supervisor, then the relationship should be many to many.

https://github.com/rubyforgood/casa/blob/master/app/models/user.rb#L18-L24

But I could be wrong

@compwron
Copy link
Collaborator

Correct, one volunteer can only be actively assigned to one supervisor at a time. We also need to keep a record of a volunteer having previously been assigned to different supervisor. Is that many-to-many? Kind of? Whatever works 😅

@drborges
Copy link
Collaborator

Thanks for the info @cliftonmcintosh, @compwron, I see what the problem is. I'll be working on a fix and some specs to cover that scenario.

@Zrrrpy Zrrrpy removed the Help Wanted This is a special label that enables github to showcase issues that want help label Sep 23, 2020
@drborges
Copy link
Collaborator

@cliftonmcintosh, @compwron I believe the PR above addresses the issue. Let me know if there's anything there you'd like changed, I'm aiming to merge it at some point this afternoon.

CASA Volunteer Portal automation moved this from In progress to Done Sep 23, 2020
drborges added a commit that referenced this issue Sep 23, 2020
…visors-after-re-assign

[#797] volunteer with two supervisors after re assign
@Zrrrpy Zrrrpy moved this from Done to Merged to QA (please move issues here after merging to QA) in CASA Volunteer Portal Sep 23, 2020
@Zrrrpy Zrrrpy moved this from Merged to QA to Done (in staging or deferred) in CASA Volunteer Portal Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
CASA Volunteer Portal
Done (in prod!)
Development

Successfully merging a pull request may close this issue.

4 participants