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

feature/sync-with-contacts-preloaded #5818

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

chopkinsmade
Copy link
Contributor

@chopkinsmade chopkinsmade commented Nov 22, 2024

Description of change

Using the django DB for individually checking if a contact in the S3 file existed was running slowly on production (200-300 milliseconds per query), with a file that contains 1.3 million rows.

To reduce the number of individual queries being executed against the DB, at the start of the job load all contacts from the DB into a python dictionary. This initial load of users takes around 4-5 minutes, however no further DB reads are required during the processing of the file.

This has been tested on a local environment with 600,000 contacts, and took 6-10 minutes to fully process the file with ENABLE_CONTACT_CONSENT_INGEST setting equal to False. Setting this value to False allows testing of the file processing logic, without making any changes to the contact in the DB.

When ENABLE_CONTACT_CONSENT_INGEST was set to True, the same 600,000 users takes 20-25 minutes to fully process the file and update the contact in the DB with the latest value for that contacts consent. As the only fields this job need to update are the consent_data and consent_data_last_modified, the update django function is used instead of save to avoid triggering the subscribed contact signals that submit additional sync jobs to the short queue

Checklist

  • Has this branch been rebased on top of the current main branch?

    Explanation

    The branch should not be stale or have conflicts at the time reviews are requested.

  • Is the CircleCI build passing?

General points

Other things to check

  • Make sure fixtures/test_data.yaml is maintained when updating models
  • Consider the admin site when making changes to models
  • Use select-/prefetch-related field lists in views and search apps, and update them when fields are added
  • Make sure the README is updated e.g. when adding new environment variables

See docs/CONTRIBUTING.md for more guidelines.

Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.49%. Comparing base (29c4ceb) to head (20d5e17).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5818      +/-   ##
==========================================
- Coverage   96.49%   96.49%   -0.01%     
==========================================
  Files        1041     1041              
  Lines       24708    24724      +16     
  Branches     1641     1644       +3     
==========================================
+ Hits        23843    23858      +15     
- Misses        709      710       +1     
  Partials      156      156              

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


🚨 Try these New Features:

@chopkinsmade chopkinsmade force-pushed the feature/sync-with-contacts-preloaded branch from be8c83c to a8cc563 Compare November 22, 2024 15:00
@chopkinsmade chopkinsmade force-pushed the feature/sync-with-contacts-preloaded branch from 7b739bb to 24dda5f Compare November 22, 2024 15:33
@chopkinsmade chopkinsmade changed the title WIP: feature/sync-with-contacts-preloaded feature/sync-with-contacts-preloaded Nov 22, 2024
@chopkinsmade chopkinsmade removed the wip label Nov 22, 2024
@chopkinsmade chopkinsmade marked this pull request as ready for review November 22, 2024 16:13
@chopkinsmade chopkinsmade requested a review from a team as a code owner November 22, 2024 16:13
@chopkinsmade chopkinsmade merged commit 2df01fd into main Nov 25, 2024
7 checks passed
@chopkinsmade chopkinsmade deleted the feature/sync-with-contacts-preloaded branch November 25, 2024 09:31
samuele-mattiuzzo pushed a commit that referenced this pull request Nov 25, 2024
* Load all contacts at start of job

* PR comments
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