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

ER-659 Nudge emails #726

Closed
wants to merge 44 commits into from
Closed

ER-659 Nudge emails #726

wants to merge 44 commits into from

Conversation

jack-coggin
Copy link
Contributor

@jack-coggin jack-coggin commented Jul 19, 2023

  • ER-659 - complete module nudge emails
  • ER-660 - start training nudge emails
  • ER-658 - complete registration nudge emails

@viezly
Copy link

viezly bot commented Jul 19, 2023

Changes preview:

Legend:

👀 Review pull request on Viezly

@jack-coggin jack-coggin temporarily deployed to test July 24, 2023 15:33 — with GitHub Actions Inactive
@jack-coggin jack-coggin temporarily deployed to test August 9, 2023 12:21 — with GitHub Actions Inactive
@jack-coggin jack-coggin temporarily deployed to test August 10, 2023 12:50 — with GitHub Actions Inactive
Copy link
Contributor

@peterdavidhamilton peterdavidhamilton left a 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?


# @param user [User]
# @return [Training::Module]
def module_in_progress(user)
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow(NotifyMailer).to receive(:continue_training)
end

it 'The notify mailer is called with the correct users' do
Copy link
Contributor

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

def queued?
Que.job_stats.any? { |job| job[:job_class] == 'MailJob' && job[:count] > 1 }
Copy link
Contributor

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?

Copy link
Contributor Author

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

@@ -321,6 +331,11 @@ def dashboard_row
data_attributes.dup.merge(module_ttc)
end

# @return [Training::Module]
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jack-coggin jack-coggin temporarily deployed to test August 10, 2023 15:12 — with GitHub Actions Inactive
Copy link
Contributor

@peterdavidhamilton peterdavidhamilton left a 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
Copy link
Contributor

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
Copy link
Contributor

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]
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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)
Copy link
Contributor

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|
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor

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
Copy link
Contributor

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?

@jack-coggin jack-coggin temporarily deployed to development August 18, 2023 12:54 — with GitHub Actions Inactive
@peterdavidhamilton peterdavidhamilton modified the milestones: rc0.9.0, email Aug 22, 2023
@jack-coggin jack-coggin deleted the ER-659-complete-module-email branch September 11, 2023 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants