Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When queueing calls with a specific call flow from the Projects page, we first check we don't call the same Contact twice (ie, if the user pasted two different phones of the same contact at the same time).
If the project's address book grew large, the method is really slow when mapping contact addresses to contacts, because it loads every contact address for the project from the database - and iterating over them. We've seen this method take ~20 seconds with ~365k contacts in a production environment.
This PR changes the method so it only works with the Contacts of the given phone numbers instead of every contact of the project. We now do two queries to the DB instead of a single one, but we query via an index, and significantly reduce the amount of records to work with.
See #944