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

Fix email template reseed problem upon updates/deletion #34

Merged
merged 7 commits into from
Feb 29, 2024

Conversation

perryzjc
Copy link
Member

@perryzjc perryzjc commented Feb 28, 2024

Pivotal Tracker Link

What this PR does:

This pull request fixes the issue of duplication of Email Templates upon reseeding the database with updated seed data. Based on the special needs from Professor Ball, it does not purge old email templates that are not present in the current seed data.

Include screenshots, videos, etc.

Special needs from Professor Ball

image

Previous Problem - Duplication of Email Templates after Reseeding Updated Email Templates

Previous Problem

After Fix

  1. No Duplication of Email Templates after Reseeding Updated Email Templates.
  2. It also considers the case to not purge old email templates that are not present in the current seed data.

Who authored this PR?

  1. Perry (Jingchao) Zhong
  2. Michael Tao

How should this PR be tested?

  • Ensure that the test suite covers scenarios for both updating existing email templates and not-removing old templates from the database upon reseeding.
  • Specifically, the tests should verify that after reseeding:
    1. Updated templates reflect the new changes without creating duplicate entries.
    2. Templates in the db, but not included in the new seed data, should not be removed.
  • What do the specs/features test?
    The specs test the reseeding process's ability to update email template (with same hash) and keep old unchanged email templates in the database accurately.

  • Are there edge cases to watch out for?
    Not on my mind yet.

Are there any complications to deploying this?

This PR is basically safe. If there are any potential risks, the update feature might overwrite the old email templates in the database if the hashed values are the same.

Relevant code of hashing can be found here

Checklist:

  • Tag someone for code review (either a coach / team member)
  • I have renamed the branch to match PivotTracker's suggested one (necessary for BlueJay) (e.g., perry/187113121-fix-email-template-reseed-issue). Any branch name will do as long as the story ID is there. You can use git checkout -b [new-branch-name]

Copy link

codecov bot commented Feb 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.77%. Comparing base (d1a4b1d) to head (755a96b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #34   +/-   ##
=======================================
  Coverage   85.77%   85.77%           
=======================================
  Files          20       20           
  Lines         668      668           
=======================================
  Hits          573      573           
  Misses         95       95           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@perryzjc perryzjc force-pushed the 187113121/bugfix/email_reseed branch from c3bc1fb to 755a96b Compare February 28, 2024 21:37
@ArushC
Copy link

ArushC commented Feb 29, 2024

LGTM. Seems like a lot of testing for a relatively simple code change, but that's good. The testing helps clarify that everything does, indeed, work as intended. In the future if we end up modifying anything other than the to/body fields in the Email Template seed data, the code might need to be updated to include those fields in the call to the "except" function.

@ArushC ArushC merged commit 771324f into main Feb 29, 2024
8 checks passed
@ArushC ArushC deleted the 187113121/bugfix/email_reseed branch February 29, 2024 03:30
@cycomachead
Copy link
Member

A few comments here:

  • The tests are great -- though I am not sure how much we should be testing the seed data.
  • the tests are currently in the controllers file, but they're not controller tests.
    U We have too many expectations in a single test case.

In general, the seeds file should not be used for migrating data. It should only create data if it doesn't exist.
In the case of email templates, the title: is the only attribute which really matters for determining whether to make an email.

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