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

Add organizer summary emails #194

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
07ea523
Update digest_mailer.rb
sampoder Aug 22, 2023
3ac0e14
Create organizer-summary.html.erb
sampoder Aug 22, 2023
7e08a8c
Rename organizer-summary.html.erb to organizer_summary.html.erb
sampoder Aug 22, 2023
325a72e
Update digest_mailer.rb
sampoder Aug 22, 2023
b399e35
Update organizer_summary.html.erb
sampoder Aug 22, 2023
2d5d748
Update digest_mailer.rb
sampoder Aug 22, 2023
5e4c9f0
Update organizer_summary.html.erb
sampoder Aug 22, 2023
28474c9
Update digest_mailer.rb
sampoder Aug 22, 2023
994b8e6
Update digest_mailer.rb
sampoder Aug 22, 2023
e1e15bf
Update digest_mailer.rb
sampoder Aug 22, 2023
19f3094
Update app/mailers/hackathons/digest_mailer.rb
sampoder Aug 22, 2023
a23ec86
Update app/views/hackathons/digest_mailer/organizer_summary.html.erb
sampoder Aug 22, 2023
c8bf0d4
Create organizer_summary.text.erb
sampoder Aug 22, 2023
4c25f3a
Restructure Post-Review
sampoder Aug 22, 2023
7e803ac
Standard
sampoder Aug 22, 2023
c633124
Update send_organizer_summaries_job.rb
sampoder Aug 22, 2023
f08d496
Merge branch 'main' into organizer-summary
sampoder Aug 22, 2023
8c594d4
Update send_organizer_summaries_job.rb
sampoder Aug 23, 2023
1f94a11
Merge branch 'main' into organizer-summary
sampoder Aug 26, 2023
af8f7ed
Merge branch 'main' into organizer-summary
sampoder Nov 11, 2023
728b784
Update send_organizer_summaries_job.rb
sampoder Nov 11, 2023
31243bc
Update app/mailers/hackathons/digest_mailer.rb
sampoder Dec 6, 2023
331ec67
Update app/views/hackathons/digest_mailer/organizer_summary.html.erb
sampoder Dec 6, 2023
1b98f29
Update app/views/hackathons/digest_mailer/organizer_summary.text.erb
sampoder Dec 6, 2023
22c52e1
Update app/mailers/hackathons/digest_mailer.rb
sampoder Dec 6, 2023
cf5b9a2
Update app/jobs/hackathons/send_organizer_summaries_job.rb
sampoder Dec 6, 2023
115a937
Update app/jobs/hackathons/send_organizer_summaries_job.rb
sampoder Dec 6, 2023
1803fe7
Merge branch 'main' into organizer-summary
sampoder Dec 6, 2023
8cb41e4
Add a test
sampoder Dec 6, 2023
41afc2d
Update organizer_summary_test.rb
sampoder Dec 6, 2023
9dec6ae
Update test/mailers/hackathons/organizer_summary_test.rb
sampoder Dec 24, 2023
9095300
Merge branch 'main' into organizer-summary
sampoder Dec 24, 2023
90e38fc
Update app/jobs/hackathons/digests_delivery_job.rb
sampoder Dec 26, 2023
8539a84
rename job
sampoder Dec 26, 2023
9d7c744
move the test
sampoder Dec 26, 2023
ee65871
that was very bad of me
sampoder Dec 26, 2023
9adae8e
run standard and pray
sampoder Dec 26, 2023
9fe0fdc
Merge branch 'main' into organizer-summary
northeastprince Dec 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions app/mailers/hackathons/digest_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,25 @@ def admin_summary(sent_digests)

mail to: Hackathons::SUPPORT_EMAIL, cc: User.admins.collect(&:email_address), subject:
end

def organizer_summary(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)) ||
Hackathon::Digest.where(created_at: 6.days.ago...Time.now)

@sent_digests_by_hackathons = @sent_digests
.includes(listings: {hackathon: {logo_attachment: :blob}})
.flat_map(&:listings).group_by(&:hackathon)
.transform_values { |listings| listings.map(&:digest).uniq }

@listed_hackathons = @sent_digests_by_hackathons.keys
.sort_by { |hackathon| @sent_digests_by_hackathons[hackathon].count }.reverse!
sampoder marked this conversation as resolved.
Show resolved Hide resolved

@listed_hackathons.each do |hackathon|
@hackathon = hackathon
@count = @digests_by_hackathons[hackathon].count
mail to: hackathon.applicant_email, subject: "We've just sent your hackathon to #{@count} hackers."
sampoder marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
13 changes: 13 additions & 0 deletions app/views/hackathons/digest_mailer/organizer_summary.html.erb
sampoder marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<% content_for :greeting do %>
<p>G'day!</p>
<% end %>
sampoder marked this conversation as resolved.
Show resolved Hide resolved

<p>
We've just sent an email about <%= @hackathon.name %> to <%= @count %> hackers. Let us know how things go!
</p>

<% content_for :signature do %>
<p>
Best of luck with everything! 🦕 💸
</p>
<% end %>
sampoder marked this conversation as resolved.
Show resolved Hide resolved