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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weekly supervisor digest mailer #1346

Merged
merged 9 commits into from Nov 15, 2020
Merged

Conversation

pollygee
Copy link
Collaborator

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 :)

Action_Controller__Exception_caught

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)

It isn't pretty

@github-actions github-actions bot added the ruby Pull requests that update Ruby code label Nov 15, 2020
@@ -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)
Copy link
Collaborator

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
Copy link
Collaborator

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.

Copy link
Collaborator

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
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

@compwron compwron merged commit 0e408f8 into main Nov 15, 2020
@compwron compwron deleted the weekly_supervisor_digest_mailer branch November 15, 2020 21:03
@pollygee
Copy link
Collaborator Author

Thanks @compwron I'll make some updates in the next couple of days when I get a few minutes to work on this. :)

This was referenced Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ruby Pull requests that update Ruby code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

supervisor receives weekly digest email of their volunteers' updates
2 participants