Repository navigation
feat(mailers): thank coaches when they reach an attendance milestone - #2985
Draft
jabawack81 wants to merge 5 commits into
Draft
jabawack81 wants to merge 5 commits into
jabawack81 wants to merge 5 commits into
Conversation
One action serves every milestone; the delivery log is keyed as coach_milestone_<n> so each milestone is sent once per member.
Picks coaches at or past a milestone in one grouped query, sends only the highest milestone reached, and skips anyone already logged for it.
Contributor
Author
|
@KimberleyCook The PR is almost ready. I have a couple of questions that should not change the code much, but I think they need answering before merge.
|
Collaborator
I am running a Grafana instance on my homelab, which consumes log lines from the If you're going to add log lines, it would be cool if they would carry the member_id, but not any personally identifiable information. I'm happy to give a demo of the Grafana dashboards and access for the maintainers. |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #2386
Problem
Coaches never hear from us for showing up. Kimberley wants a thank-you email once a coach has attended 5 workshops, possibly again at 10, 15, 20.
Change
Same shape as the three-month chaser: a daily rake task enqueues a job, the job calls a service, the service picks members and hands them to
MemberMailer.CoachMilestoneEmailServicecounts attended coach invitations for past workshops in one grouped query (it hits the partial index from Speed up /coaches: partial index and database-side coach count #2900), keeps coaches at or past a milestone who are not banned and have accepted the ToC, and sends each the highest milestone they have reached. Anyone already logged for that milestone or a higher one is skipped.MemberMailer#coach_milestonerenders Kimberley's copy with the number filled in.EmailDeliverylogs through a newemail_type_for_loghook, defaultaction_name, so existing callers are unchanged. The mailer overrides it tocoach_milestone_<n>so several milestones can share one action without hitting the(member_id, email_type)unique index.MILESTONES = [5]. Adding more is a one-line change.I did not use a callback on
attended: attendance is set from check-in and the admin toggle and gets corrected after the fact. A daily sweep handles that; a callback would not.Verification
MILESTONESstubbed to[5, 10].:jsspecs, which fail locally for lack of Chromium's system libraries. RuboCop clean.Review notes
rake chaser:coach_milestones, daily, any time.Post-deploy
The morning after the first run,
MemberEmailDelivery.where("email_type LIKE 'coach_milestone_%'").countshould match the number of coaches at 5 or more, with no failed jobs. The day after, it should not have moved.