Skip to content

Commit d87269d

Browse files
dquach217sman591cbaudouinjrsemantic-release-botJeremyRudman
authored
feat: Automatically remind people to RSVP (#175)
* feat: add rsvp reminder email to trigger and automation process based on loose rules * feat: add the rsvp reminder email to queue_reminder_email class * fix: fix issue with hound * fix: resolve issues with linting and fix conditionals * fix: more linting issues * fix: more more linting issues * seperate the two functions * update on per Stuart instruction, make this more automated * forgot to commit this * remove this unnecessary piece of code * fix linting issues * remove since we are not using this * Update app/models/user.rb Co-Authored-By: Stuart Olivera <stuart@stuartolivera.com> * forgot to add end * resolve for hound * fix(dashboard): Fixes security vulnerability that allowed event_tracking role to access Dashboard (#215) * chore(release): 1.22.3 [skip ci] ## [1.22.3](v1.22.2...v1.22.3) (2020-05-16) ### Bug Fixes * **dashboard:** Fixes security vulnerability that allowed event_tracking role to access Dashboard ([#215](#215)) ([](74a40ad)) ### Styles * **check-in:** Changes table header to be more descriptive ([#207](#207)) ([](889fbd0)) * **config:** Removes unused event_is_over flag ([#208](#208)) ([](0c73e66)) * build(deps): Upgrade yarn (#212) * build(deps): Upgrade yarn * build(deps): Upgrade gems * build(deps): Remove obsolete gems * v0.0.0 * build(deps): Update semantic-release * fix(questionnaire): visual bug in school autocomplete school dropdown the css was set for an "a" tag when the list was made up of divs so I switched the css to work for the "div" tag in the autocomplete * fix(questionnaire): visual bug in school autocomplete school dropdown the css was set for an "a" tag when the list was made up of divs so I switched the css to work for the "div" tag in the autocomplete. I also hide a element that was not present earlier * build(deps): Upgrades Rails to 5.2.4.3 * build(deps): Upgrades gems Co-authored-by: Jeremy Rudman <jeremyrudman@gmail.com> * fix: Fixes date issue with RSVP reminder job * fix: Fixes bug where message would not send * refactor: Change subject of RSVP reminder * refactor: Verbage changes, updated reminder message * 2.0: Removes SparkPost mentions for 2.0 * fix: Fixes timezone issues * fix: More timezone issues Co-authored-by: Stuart Olivera <stuart@stuartolivera.com> Co-authored-by: Chris Baudouin, Jr <cjb5326@rit.edu> Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net> Co-authored-by: Jeremy Rudman <jeremyrudman@gmail.com> Co-authored-by: Chris Baudouin, Jr <chrisbaudouinjr@icloud.com>
1 parent 2e9379f commit d87269d

File tree

7 files changed

+51
-1
lines changed

7 files changed

+51
-1
lines changed

app/mailers/user_mailer.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@ def bulk_message_email(message_id, user_id, message = nil, use_examples = false)
1616

1717
def incomplete_reminder_email(user_id)
1818
@user = User.find_by_id(user_id)
19-
return if @user.blank? || @user.admin? || @user.questionnaire || Time.now.to_date > Date.parse(HackathonConfig["last_day_to_apply"])
19+
return if @user.blank? || @user.admin? || @user.questionnaire || Time.now.in_time_zone.to_date > Date.parse(HackathonConfig["last_day_to_apply"]).in_time_zone.to_date
2020

2121
Message.queue_for_trigger("user.24hr_incomplete_application", @user.id)
2222
end
23+
24+
def rsvp_reminder_email(user_id)
25+
@user = User.find_by_id(user_id)
26+
return if @user.blank? || !@user.questionnaire.acc_status == "accepted" || Time.now.in_time_zone.to_date > Date.parse(HackathonConfig["event_start_date"]).in_time_zone.to_date
27+
28+
Message.queue_for_trigger("questionnaire.rsvp_reminder", @user.id)
29+
end
2330
end

app/models/message.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Message < ApplicationRecord
3737
"questionnaire.late_waitlist" => "Questionnaire Status: Waitlisted, Late",
3838
"questionnaire.rsvp_confirmed" => "Questionnaire Status: RSVP Confirmed",
3939
"questionnaire.rsvp_denied" => "Questionnaire Status: RSVP Denied",
40+
"questionnaire.rsvp_reminder" => "Questionnaire: RSVP Reminder",
4041
"user.24hr_incomplete_application" => "User: Incomplete application (24 hours later)",
4142
"bus_list.new_captain_confirmation" => "Bus List: New captain confirmation",
4243
"bus_list.notes_update" => "Bus List: Updated notes (manually triggered)"

app/models/questionnaire.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Questionnaire < ApplicationRecord
1010
before_validation :clean_negative_dietary_restrictions
1111
after_create :queue_triggered_email_create
1212
after_update :queue_triggered_email_update
13+
after_update :queue_triggered_email_rsvp_reminder
1314
after_save :update_school_questionnaire_count
1415
after_destroy :update_school_questionnaire_count
1516

@@ -249,4 +250,18 @@ def queue_triggered_email_update
249250
def queue_triggered_email_create
250251
Message.queue_for_trigger("questionnaire.#{acc_status}", user_id)
251252
end
253+
254+
def queue_triggered_email_rsvp_reminder
255+
if saved_change_to_acc_status? && acc_status == "accepted"
256+
days_remaining = Date.parse(HackathonConfig["event_start_date"]).in_time_zone.to_date - Time.now.in_time_zone.to_date
257+
if days_remaining > 14
258+
deliver_date = 7.days.from_now
259+
elsif days_remaining > 10
260+
deliver_date = 5.days.from_now
261+
elsif days_remaining > 3
262+
deliver_date = 2.days.from_now
263+
end
264+
UserMailer.rsvp_reminder_email(user_id).deliver_later(wait_until: deliver_date) if deliver_date.present?
265+
end
266+
end
252267
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Missing RSVP
2+
3+
<div style="text-align: center;">
4+
<h1>Are you coming to {{hackathon_name}}?</h1>
5+
<h3>Let us know if we should expect you there!</h3>
6+
<p>
7+
<a href="{{accept_rsvp_url}}" class="button" target="_blank">Yes, I will Attend &raquo;</a>
8+
<a href="{{deny_rsvp_url}}" class="button" target="_blank">No, I Can't Attend &raquo;</a>
9+
<br>
10+
<small><i>Link not working? Go to <a href="{{rsvp_url}}">{{rsvp_url}}</a></i></small>
11+
</p>
12+
</div>

db/seeds.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"questionnaire.accepted" => "You've been accepted!",
1616
"questionnaire.denied" => "Your application status",
1717
"questionnaire.rsvp_confirmed" => "RSVP Confirmation",
18+
"questionnaire.rsvp_reminder" => "Are you coming to #{HackathonConfig['name']}?",
1819
"user.24hr_incomplete_application" => "Incomplete application",
1920
"bus_list.new_captain_confirmation" => "You're a bus captain!",
2021
"bus_list.update_notes" => "Bus Update"
@@ -25,6 +26,7 @@
2526
"questionnaire.accepted" => "Accepted email",
2627
"questionnaire.denied" => "Denied email",
2728
"questionnaire.rsvp_confirmed" => "RSVP confirmed email",
29+
"questionnaire.rsvp_reminder" => "RSVP Reminder",
2830
"user.24hr_incomplete_application" => "Incomplete application (24-hour reminder)",
2931
"bus_list.new_captain_confirmation" => "New bus captain confirmation",
3032
"bus_list.update_notes" => "Bus list update"

test/controllers/user_mailer_test.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ class UserMailerTest < ActionMailer::TestCase
2929
end
3030
end
3131

32+
context "upon scheduled rsvp reminder email" do
33+
setup do
34+
@user = create(:user, email: "test@example.com")
35+
@message = create(:message, subject: "Are you coming to HackFoo?", type: "automated", trigger: "questionnaire.rsvp_reminder_email")
36+
37+
should "queue reminder bulk message" do
38+
assert_difference "enqueued_jobs.size", 1 do
39+
UserMailer.rsvp_reminder_email(@user.id).deliver_later
40+
end
41+
end
42+
end
43+
end
44+
3245
context "with customized HackathonConfig" do
3346
setup do
3447
@user = create(:user, email: "test@example.com")

vendor/cache/puma-4.3.4.gem

171 KB
Binary file not shown.

0 commit comments

Comments
 (0)