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

Improve locks and upserts in data-sink-worker #1451

Merged
merged 8 commits into from
Sep 11, 2023

Conversation

garrrikkotua
Copy link
Contributor

@garrrikkotua garrrikkotua commented Sep 8, 2023

Changes proposed ✍️

What

🤖 Generated by Copilot at fcf1da3

This pull request refactors and optimizes the data sink worker service, which handles the processing of organization, member, and activity data. It simplifies the queries and updates of the organization and member repositories, improves the performance and correctness of the member and activity services, and adds a new common function for array comparison. It also removes some unused or redundant code related to the segmentId field, which was part of a removed feature.

🤖 Generated by Copilot at fcf1da3

We are the masters of the code, we make it fast and clean
We purge the useless segments, we find the members by their name
We use the common functions, we loop through the fields of change
We are the rebels of the data, we crush the bugs with rage

Why

How

🤖 Generated by Copilot at fcf1da3

  • Simplify queries and lock keys by removing segmentId condition and parameter (link, link, link)
  • Refactor update methods and updateCache method of OrganizationService class to use loops instead of multiple if statements or assignments (link, link, link, link)
  • Move addToSegment call from if branch to else branch in updateMember method of MemberService class to avoid redundant calls (link)
  • Add length check to member emails array before comparing it with dbMember emails array in updateMember method of MemberService class to avoid unnecessary comparisons and updates (link)
  • Replace areArraysEqual function with firstArrayContainsSecondArray function in import statement of MemberService class to use the new utility function from common library (link, link)
  • Remove displayName variable and conditional assignment from createOrUpdate method of OrganizationService class to simplify code and avoid unnecessary variables (link)

Checklist ✅

  • Label appropriately with Feature, Improvement, or Bug.
  • Add screehshots to the PR description for relevant FE changes
  • New backend functionality has been unit-tested.
  • API documentation has been updated (if necessary) (see docs on API documentation).
  • Quality standards are met.

Copy link
Collaborator

@epipav epipav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

included one comment

@garrrikkotua garrrikkotua merged commit 3c9e332 into main Sep 11, 2023
8 checks passed
@garrrikkotua garrrikkotua deleted the improve/locks-and-upserts branch September 11, 2023 09:01
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.

None yet

3 participants