Skip to content

[BB-4141] Add task for daily email report

Boros Gábor requested to merge arjun/bb-4141 into master

Created by: arjunsinghy96

Adds the daily report task to marketing app

Related Tickets

BB-4141

Testing Instructions

Testing report email is sent after sending followup emails.

  1. Checkout to this branch
  2. Run make migrate if you haven't already after the addition of marketing app.
  3. Run dev server
  4. Visit http://localhost:5000/admin/marketing/emailtemplate/add/ and add an active template with send_after_days set to 1.
  5. 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.
  6. Feel free to create more records of EmailTemplate and Subscriber with different values
  7. In another terminal open the django shell using make shell
  8. Import the tasks using from marketing.tasks import send_followup_emails, send_report
  9. Run send_followup_emails()
  10. In server logs, verifiy that the report was sent for all the triggered emails.
  11. Run the send_followup_emails() task again and verify that this time the report email says No emails were sent today to P&T and trail users.

Testing send_report standalone

  1. In django shell import send_report task
  2. send_report accepts a dictionary with Email names as key and List of emails as values.
  3. Trigger send_report task using send_report({"Welcome Email": ["arjun@example.com", "user2@example.com"]})
  4. In server logs, verify that the email is sent with appropriate template.
  5. Change the values (increase keys and emails) and call send_report task.
  6. Verify that email is sent with all the records passed.

Author Notes

  1. The send_report task is scheduled right after the send_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.

Merge request reports