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

Merge organizations asynchronously #1825

Merged
merged 3 commits into from
Nov 9, 2023
Merged

Merge organizations asynchronously #1825

merged 3 commits into from
Nov 9, 2023

Conversation

sausage-todd
Copy link
Contributor

@sausage-todd sausage-todd commented Nov 7, 2023

Changes proposed ✍️

What

🤖 Generated by Copilot at 13bd026

The pull request adds support for asynchronous merge operation of organizations using a worker queue. It modifies the OrganizationRepository, OrganizationService, and organizationMerge API classes to handle the new status column and the mergeAsync function. It also adds new files and functions to create and process the OrganizationMergeMessage in the worker queue and optionally notify the frontend. It also includes SQL migration scripts to update the database schema.

🤖 Generated by Copilot at 13bd026

We are the masters of the merge
We send our commands to the queue
We face the errors and the purge
We notify the frontend with the truth

Why

How

🤖 Generated by Copilot at 13bd026

  • Refactor merge function in OrganizationService class to use worker queue (link,link,link,link)
  • Destructure and rename function parameters for clarity (link)
  • Rename original function to mergeSync and add new function mergeAsync (link)
  • Update status of organization to merge to 'pending' in mergeAsync (link)
  • Send message to worker queue with sendOrgMergeMessage function (link,link,link)
  • Update status of organization to merge to 'in-progress' in mergeSync (link)
  • Return 203 status code if merge operation was already in progress (link)
  • Update status of organization to merge to 'ready' in mergeSync (link)
  • Do status updates outside and inside transaction as appropriate (link,link)
  • Add orgMergeWorker function to handle merge operation in worker queue (link,link,link)
    • Receive tenant id, primary and secondary organization ids, and notify frontend flag as parameters (link)
    • Create user context and organization service instance (link)
    • Call mergeSync function to perform actual merge operation (link)
    • Catch and log any errors (link)
    • Notify frontend with websocket message if flag is true (link)
    • Add 'org-merge' service case to workerFactory function (link,link)
    • Type check event parameter with OrganizationMergeMessage type (link,link)
  • Modify findAndCountAllToMerge function in OrganizationRepository class to include and filter by status column (link,link,link,link)
    • Add status column to select query for organizations to merge (link)
    • Add filter condition to only select organizations with status 'ready' (link)
    • Add status column to select query for cte (link)
    • Add status column to select query for final result set (link)
  • Add setMergeStatus function to OrganizationRepository class to update status of organization to merge (link)
    • Use original and to merge ids as parameters (link)
    • Return boolean indicating whether status was changed or not (link)
  • Add SQL migration scripts to drop and add status column to organizationToMerge table (link,link)
    • Drop status column in U1699357748__org-merge-status.sql (link)
    • Add status column in V1699357748__org-merge-status.sql (link)

Checklist ✅

  • Label appropriately with Feature, Improvement, or Bug.
  • Add screenshots 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.

@sausage-todd sausage-todd force-pushed the org-merge-timeout branch 2 times, most recently from 7c3a31a to f8750c8 Compare November 7, 2023 12:46
@sausage-todd sausage-todd merged commit bdca46b into main Nov 9, 2023
8 checks passed
@sausage-todd sausage-todd deleted the org-merge-timeout branch November 9, 2023 11:11
sausage-todd added a commit that referenced this pull request Nov 9, 2023
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

2 participants