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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weekly supervisor digest mailer #1346
Conversation
@@ -25,6 +25,20 @@ def case_contacts_ordered_by_occurred_at | |||
object.case_contacts.sort_by(&:occurred_at) | |||
end | |||
|
|||
def case_contacts_latest | |||
object.case_contacts.max_by(&:occurred_at) |
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 should be a scope on the model, to avoid having to pull all the case contacts every time.
end | ||
|
||
def successful_contacts_this_week | ||
this_week = Date.today - 7.days..Date.today |
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 thought we already had something like this somewhere... I want to have all this logic in one central place. I will take a look around.
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 would like it if we could split out a helper or something(?) to hold all our date-related logic like this
Existing in user:
def recent_contacts_made(days_counter = 60)
case_contacts.where(contact_made: true, occurred_at: days_counter.days.ago..Date.today).size
end
@@ -0,0 +1,6 @@ | |||
desc "Send an email to supervisors each week to share an overview of their volunteers' activities" | |||
task send_supervisor_digest: :environment do |
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.
We'll need a cron for this or similar- I assume heroku has something for this?
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 wrote a mailer for reminders when court reports are due. I believe I was told to create a task that would be run by heroku. I never followed up about that to see if that was scheduled. I would assume heroku has something for that, but I'm not super familiar. I can look it up and try to set that up once this gets merged so we can set it up for this one and the court report reminder.
Thanks @compwron I'll make some updates in the next couple of days when I get a few minutes to work on this. :) |
What github issue is this PR for, if any?
Resolves #23
What changed, and why?
Added a weekly digest email to be sent to supervisors with the week in review of the contacts attempted for each of their volunteers.
How will this affect user permissions?
N/A
How is this tested? (please write tests!) 馃挅馃挭
I added a preview to for the emails so we can view the sample email.
Screenshots please :)
It isn't beautiful but the info is there. Maybe we can find someone good at making things pretty help make this look cooler!
Feelings gif (optional)