-
Notifications
You must be signed in to change notification settings - Fork 0
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
ER-659 Nudge emails #726
ER-659 Nudge emails #726
Conversation
jack-coggin
commented
Jul 19, 2023
•
edited by jira
bot
Loading
edited by jira
bot
- ER-659 - complete module nudge emails
- ER-660 - start training nudge emails
- ER-658 - complete registration nudge emails
Changes preview: |
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.
Are we testing for duplicate mail jobs?
app/services/nudge_mail.rb
Outdated
|
||
# @param user [User] | ||
# @return [Training::Module] | ||
def module_in_progress(user) |
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.
I'd say because this isn't performing its own logic anymore and is just calling a chine of methods, we could remove it.
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.
spec/services/nudge_mail_spec.rb
Outdated
allow(NotifyMailer).to receive(:continue_training) | ||
end | ||
|
||
it 'The notify mailer is called with the correct users' do |
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.
Not essential but it can be useful to write as if the audience is not a developer.
it 'emails...
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.
app/jobs/mail_job.rb
Outdated
private | ||
|
||
def queued? | ||
Que.job_stats.any? { |job| job[:job_class] == 'MailJob' && job[:count] > 1 } |
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.
HMW get the same check for our dashboard?
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.
I was looking at a way to stop duplicate jobs being added to the queue in the first place, but wasn't able to make much progress. Instead, I've added a helper to guard against duplicate jobs in the run method of the jobs dbbefa7
app/models/user.rb
Outdated
@@ -321,6 +331,11 @@ def dashboard_row | |||
data_attributes.dup.merge(module_ttc) | |||
end | |||
|
|||
# @return [Training::Module] |
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.
I think we should let the course object answer and not add an extra method on user. Is the doc accurate?
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.
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.
Would creating a reusable mail spec matcher be a good idea at some point? With two variables, a list of users it should contact, and a list it should exclude.
@@ -0,0 +1,5 @@ | |||
module SchedulerHelper |
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.
I suggest we instead create a base job for the application, similar to the convention Rails adopts with controllers.
The predicate could be more descriptive. It's queued with the first criteria, but what we are interested in is the second that checks for duplication.
When the run is skipped, how can we get notified that was the reason?
@@ -0,0 +1,27 @@ | |||
class NudgeMail |
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.
What's the benefit of combining email nudges into one job, rather than dedicated jobs for each type?
|
||
private | ||
|
||
# @return [ActiveRecord::Relation] |
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.
Run .class
and use the return value for the doc.
end | ||
end | ||
|
||
context 'when users are a month old and have completed registration but not started training' do |
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.
I'm imagining a month old baby learning about how they should be cared for. 🍼
@@ -0,0 +1,105 @@ | |||
require 'rails_helper' | |||
|
|||
RSpec.describe NudgeMail do |
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.
Can with progress
be leveraged here?
|
||
# @return [Array<User>] | ||
def continue_training_recipients | ||
recent_visits = Ahoy::Visit.where(started_at: 4.weeks.ago.end_of_day..Time.zone.now) |
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.
If this were a scope on the visit I think it would help
@@ -150,6 +150,13 @@ | |||
t.index ["user_id"], name: "index_responses_on_user_id" | |||
end | |||
|
|||
create_table "training_module_records", force: :cascade do |t| |
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.
I still think we need to articulate what this is for. I'd expect to see an explicit stamp for the date it went live.
Would a new Dev expect the updated_at time to track the modification time of the entry for example...
What is this thing responsible for?
@@ -87,4 +87,38 @@ | |||
end | |||
end | |||
end | |||
|
|||
describe 'training email opt in' do |
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.
Can we collaborate and workshop the doc format this puts out.
|
||
allow(NotifyMailer).to receive(:continue_training) | ||
end | ||
|
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.
My tactic is to use variables if I can make code/specs easier to skim read. Does using a variable to hold the module object improve your reading of this spec?
@@ -0,0 +1,8 @@ | |||
class MailJob < Que::Job |
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.
Would this job benefit from any logging like the first job?