-
Notifications
You must be signed in to change notification settings - Fork 6
Add organizer summary emails #194
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
base: main
Are you sure you want to change the base?
Changes from 32 commits
07ea523
3ac0e14
7e08a8c
325a72e
b399e35
2d5d748
5e4c9f0
28474c9
994b8e6
e1e15bf
19f3094
a23ec86
c8bf0d4
4c25f3a
7e803ac
c633124
f08d496
8c594d4
1f94a11
af8f7ed
728b784
31243bc
331ec67
1b98f29
22c52e1
cf5b9a2
115a937
1803fe7
8cb41e4
41afc2d
9dec6ae
9095300
90e38fc
8539a84
9d7c744
ee65871
9adae8e
9fe0fdc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| class Hackathons::SendOrganizerSummariesJob < ApplicationJob | ||
sampoder marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| def perform(sent_digests) | ||
| # This reloads the (possible) sent_digests array as an | ||
| # ActiveRecord::Relation so that we can use includes to prevent an N+1. | ||
| @sent_digests = Hackathon::Digest.where(id: sent_digests.map(&:id)) | ||
|
|
||
| @sent_digests_by_hackathons = @sent_digests | ||
| .includes(listings: :hackathon) | ||
| .flat_map(&:listings).group_by(&:hackathon) | ||
| .transform_values { |listings| listings.map(&:digest).uniq } | ||
|
|
||
| @listed_hackathons = @sent_digests_by_hackathons.keys | ||
| @listed_hackathons.each do |hackathon| | ||
| sent_digests = @digests_by_hackathons[hackathon] | ||
| Hackathons::DigestMailer.organizer_summary(hackathon, sent_digests).deliver_later if @sent_digests.any? | ||
| end | ||
| end | ||
| end | ||
sampoder marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
|
|
||
| <p> | ||
| We've just sent an email about <%= @hackathon.name %> to <%= @count %> hackers. | ||
| </p> | ||
|
|
||
| <% content_for :signature do %> | ||
| <p> | ||
| Best of luck with everything! 🦕 💸 | ||
| </p> | ||
| <% end %> | ||
sampoder marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| We've just sent an email about <%= @hackathon.name %> to <%= @count %> hackers. | ||
|
|
||
| <% content_for :signature do %> | ||
| Best of luck with everything! 🦕 💸 | ||
| <% end %> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| require "test_helper" | ||
|
||
|
|
||
| class Hackathons::OrganizerSummaryTest < ActionMailer::TestCase | ||
| test "organizer_summary" do | ||
| sent_digests = [hackathon_digests(:one)] | ||
| hackathon = hackathon_digests(:one).listings.first.hackathon | ||
| mail = Hackathons::DigestMailer.organizer_summary(hackathon, sent_digests) | ||
|
|
||
| assert_equal "We've just notified #{sent_digests.count} hackers about #{hackathon.name}!", mail.subject | ||
| assert_equal [hackathon.applicant.email_address], mail.to | ||
|
|
||
| assert_match "We've just sent an email about #{hackathon.name} to #{sent_digests.count} hackers.", mail.body.encoded | ||
|
|
||
| # Email CAN-SPAM compliance | ||
| assert_match Hackathons::HACK_CLUB_ADDRESS[:full], mail.body.encoded | ||
| end | ||
| end | ||
Uh oh!
There was an error while loading. Please reload this page.