-
-
Notifications
You must be signed in to change notification settings - Fork 198
Email users code #2449
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
Draft
jonodrew
wants to merge
4
commits into
master
Choose a base branch
from
email-users-code
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Email users code #2449
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class SendThreeMonthEmailJob < ApplicationJob | ||
| queue_as :default | ||
|
|
||
| def perform | ||
| ThreeMonthEmailService.send_chaser | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| module EmailDelivery | ||
| extend ActiveSupport::Concern | ||
|
|
||
| private | ||
|
|
||
| def log_sent_email | ||
| member = params[:member] | ||
| return unless member | ||
|
|
||
| MemberEmailDelivery.create!( | ||
| member: member, | ||
| subject: mail.subject, | ||
| body: mail.body.to_s, | ||
| to: mail.to, | ||
| cc: mail.cc, | ||
| bcc: mail.bcc | ||
| ) | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,16 @@ | ||
| class MemberMailer < ApplicationMailer | ||
| include EmailHeaderHelper | ||
| include EmailDelivery | ||
|
|
||
| after_action :log_sent_email, only: [:chaser] | ||
|
|
||
| def chaser | ||
| @member = params[:member] | ||
| subject = "It’s been a while, how are you doing? ♥️" | ||
| mail mail_args(@member, subject, '[email protected]', '[email protected]') do |format| | ||
| format.html {render 'three_month_chaser'} | ||
| end | ||
| end | ||
|
|
||
| def welcome(member) | ||
| if member.student? | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| class MemberEmailDelivery < ApplicationRecord | ||
| belongs_to :member, polymorphic: true, optional: true | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class ThreeMonthEmailService | ||
| def self.send_chaser | ||
| members = Member.joins(:workshop_invitations).where("workshop_invitations.create_at >= ?", 3.months.ago).distinct | ||
| members.each do |member| | ||
| MemberMailer.with(member: member).chaser.deliver_later | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| %h1 Hi #{@member.name}, | ||
|
|
||
| %p | ||
| We’ve noticed you haven’t been to a codebar workshop in a little while, and we just wanted to check in. We know life gets busy, but we’d love to understand how things are going for you and whether there’s anything we can do to make it easier or more valuable for you to join again. | ||
| %p | ||
| If you have a minute, could you please share your thoughts in this short form? 👉 https://forms.gle/tEETvC3zYP9mcLar7 | ||
|
|
||
| %p | ||
| Or, if you’re thinking about coming back soon, we’ve got some great upcoming workshops and events you might like to join 👉https://codebar.io/events/ | ||
|
|
||
| %p | ||
| Your feedback really helps us make codebar more welcoming and useful for everyone in our community 💜 | ||
|
|
||
| %p | ||
| We’d love to see you again soon! | ||
|
|
||
| %p | ||
| #{"-- "} | ||
| %br | ||
| Warmly, | ||
| The Codebar Team |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Minor: When looking up records with #first or #last, and you expect there to be a record, prefer the exception-raising
#first!and#last!. Those exceptions are even clearer signals, crashing earlier than "NoMethodError nil does not respond to #member".You're making nice tests!