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

Refactor email and calendar auto contact creation to create them by batch #5901

Closed
bosiraphael opened this issue Jun 17, 2024 · 1 comment · Fixed by #6038
Closed

Refactor email and calendar auto contact creation to create them by batch #5901

bosiraphael opened this issue Jun 17, 2024 · 1 comment · Fixed by #6038
Assignees
Labels
scope: backend Issues that are affecting the backend side only type: chore

Comments

@bosiraphael
Copy link
Contributor

Scope & Context

When too many contacts are created in the same query, we have an error.

Technical inputs

Paginate contact creation to avoid this problem:

  • Create a CONTACTS_CREATION_BATCH_SIZE constant
  • Loop over the contacts to create
  • Insert them by batch
Copy link

greptile-apps bot commented Jun 17, 2024

Refactor the contact creation logic to paginate contact creation using a constant CONTACTS_CREATION_BATCH_SIZE. Loop over the contacts to create and insert them by batch.

  1. Define CONTACTS_CREATION_BATCH_SIZE in a constants file (e.g., constants.py):
CONTACTS_CREATION_BATCH_SIZE = 100  # Adjust the batch size as needed
  1. Update the contact creation logic to use batching. For example, in contact_service.py:
from .constants import CONTACTS_CREATION_BATCH_SIZE

# Assuming `contacts` is a list of contacts to be created
for i in range(0, len(contacts), CONTACTS_CREATION_BATCH_SIZE):
    batch = contacts[i:i + CONTACTS_CREATION_BATCH_SIZE]
    # Insert the batch of contacts
    insert_contacts(batch)
  1. Ensure the insert_contacts function handles the batch insertion logic.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: backend Issues that are affecting the backend side only type: chore
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

1 participant