[BB-4141] Add task for daily email report
Created by: arjunsinghy96
Adds the daily report task to marketing
app
Related Tickets
Testing Instructions
Testing report email is sent after sending followup emails.
- Checkout to this branch
- Run
make migrate
if you haven't already after the addition of marketing app. - Run dev server
- Visit http://localhost:5000/admin/marketing/emailtemplate/add/ and add an active template with send_after_days set to 1.
- Visit http://localhost:5000/admin/marketing/emailtemplate/add/ and add a subscriber with
trial_started_at
set to yesterday's date and a time less than now. - Feel free to create more records of
EmailTemplate
andSubscriber
with different values - In another terminal open the django shell using
make shell
- Import the tasks using
from marketing.tasks import send_followup_emails, send_report
- Run
send_followup_emails()
- In server logs, verifiy that the report was sent for all the triggered emails.
- Run the
send_followup_emails()
task again and verify that this time the report email saysNo emails were sent today to P&T and trail users.
send_report
standalone
Testing - In django shell import
send_report
task -
send_report
accepts a dictionary withEmail names
as key andList of emails
as values. - Trigger
send_report
task usingsend_report({"Welcome Email": ["arjun@example.com", "user2@example.com"]})
- In server logs, verify that the email is sent with appropriate template.
- Change the values (increase keys and emails) and call
send_report
task. - Verify that email is sent with all the records passed.
Author Notes
- The
send_report
task is scheduled right after thesend_followup_email
with a list of followup emails send. I think it made more sense there because we wouldn't have to make a DB query to get the sent emails and it is the next step right after sending all followup emails.