-
-
Notifications
You must be signed in to change notification settings - Fork 486
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
Add notifications for volunteer birthdays (#5316) #5328
Conversation
6107a2d
to
f73386a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a completely drive by review from a new guy to the area. Please take it or leave it completely. Just wanted to provide a few thoughts. Generally looks good!
@davidgumberg What's the reasoning behind splitting this into 2 prs? |
f73386a
to
ce8834c
Compare
More than the size of the changes, I just wanted to make sure that adding a date of birth column to the Users table was desired, but since it's only use case is the birthday notification I think I'll make it one PR so they can be looked at together. |
c6d9c88
to
319d735
Compare
319d735
to
87d71b5
Compare
a97c1e9
to
6ae6e08
Compare
app/models/volunteer.rb
Outdated
@@ -57,6 +63,10 @@ class Volunteer < User | |||
.order(:display_name) | |||
} | |||
|
|||
scope :birthday_next_month, -> { | |||
where("EXTRACT(month from date_of_birth) = ?", DateTime.now.next_month.month) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of raw SQL, use Rails helpers here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried, but could not come up with a way to do this without using EXTRACT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try this
where(date_of_birth: Date.today.beginning_of_month.next_month..Date.today.end_of_month.next_month)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that this range will only include date_of_birth's that fall on the next month of this year.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Yeah, the only solution I saw started to feel over-engineered. There's no user input in this, so that makes me more comfortable. Keep as is.
Absolutely love all the tests @davidgumberg! |
694653b
to
f763e01
Compare
f763e01
to
f1f1497
Compare
f1f1497
to
0ffc83a
Compare
@schoork Thanks for the review, I've implemented the suggestions you made (minus using rails helpers for |
@@ -44,4 +44,16 @@ def formatted_reset_password_sent_at | |||
def formatted_invitation_sent_at | |||
formatted_timestamp(:invitation_sent_at) | |||
end | |||
|
|||
def formatted_birthday | |||
return "" unless object.date_of_birth.respond_to?(:strftime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the NoMethodError guards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really awesome work @davidgumberg! Love all the tests. Had never heard of the travel_to DATE
. That's pretty nifty!
Thanks for the review and feedback! I got the idea for |
@davidgumberg Thanks for the work here. I want to share this update with the casa stakeholders. They will love it. how many days out does the birthday need to be to receive a notification? |
Thanks @bcastillo32. Actually, there is a heroku task that will need to be added to run once a month by whoever administers the CASA application, and it will notify volunteers in the same cadence as the youth volunteer reminders, on the 15th (or whichever day of the month the administrator sets the task to run) of each month, users will receive a notification about all volunteer birthdays that are coming in the next month. Please let me know if that behavior is aligned with what the stakeholders requested, and if not, I can write another PR to update the changes to better reflect their request. |
thanks @davidgumberg ! I will reach out to the CASA team to confirm if the proposed schedule suits their requirements. I plan to inform them of the suggested cadence, and if they have any objections and want to propose a different one, we can consider it. Thank you once again for your valuable input! |
Resolves #5316
This PR adds notifications for volunteer birthdays.
Adds an optional 'date_of_birth' parameter to the Users model, which is a prerequisite for being able to notify supervisors of upcoming volunteer birthdays.
Adds a
birthday_next_month
scope toVolunteer
, volunteer birthday notification, and rake task for creating the notifications.Permissions
Volunteers can edit their own DOB, and supervisors and admins from the same org as a volunteer are able to edit the volunteer's DOB.
Tests
I've added tests for the views, and permissions, and a validation rule for the DOB's (they must be in the past.) and for the notification message, and notification rake task.