NEUSPRT-266: Optimize log viewing for a contact #135
Merged
+8
−3
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.
Overview
This pr optimizes the code for viewing the change logs for a contact.
Technical Details
Currently during fetching the change log for a contact we also fetch information for modifier contact here once for each row from the log table. This can give timeout errors on big databases as each call to the function getDisplayAndImage results in one query being executed. Even if same modifier changed the one contact multiple times we will have multiple queries for fetching same information for same modifier.
This pr changes the code to store the modifier information in an array and only query the modifier info if its not already available in the array thus results in significantly lesser number of queries for large change logs.