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

DB Optimization - Template History #2254

Open
6 tasks
k-macmillan opened this issue Jan 17, 2025 · 0 comments
Open
6 tasks

DB Optimization - Template History #2254

k-macmillan opened this issue Jan 17, 2025 · 0 comments

Comments

@k-macmillan
Copy link
Member

k-macmillan commented Jan 17, 2025

User Story - Business Need

Reducing the number of queries against our data is necessary to maintain a stable product. Template History should be cached in local memory.

  • Ticket is understood, and QA has been contacted (if the ticket has a QA label).

User Story(ies)

As a VA Notify reliability dev
I want to reduce unnecessary DB calls
So that our db is only used when necessary

Additional Info and Resources

send_email_to_provider and send_sms_to_provider call dao_get_template_by_id, passing notification.template_version. New versions are created for every edit, so this is 100% something that should be cached, as any update would be a new version, and would update the cache.

Image

Acceptance Criteria

  • Uses a dataclass for the necessary fields
  • Takes the input data (id, version) and returns a TemplateDataDict dataclass
  • Uses @cached(cache=TTLCache(maxsize=1024, ttl=600))
  • 10 notifications sent using the same provider should query the database at most once per worker
  • This work is added to the sprint review slide deck (key win bullet point and demo slide)

QA Considerations

Should be no difference for end-users.

Potential Dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants