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

CMS-647: sync park-operation-sub-areas across environments #94

Open
wants to merge 3 commits into
base: alpha
Choose a base branch
from

Conversation

diego-oxd
Copy link
Collaborator

@diego-oxd diego-oxd commented Jan 28, 2025

Jira Ticket

CMS-647

Description

We are trying to sync subareas across environments. The goal is have every env match what prod has.
On a high level, there are 2 main operations going on for each environment.

  1. If a subarea exists in prod, but not in the environment -- > the subarea will be created in the environment
  2. If a subarea exists in the env, but not in prod -- > the subarea will be marked as inactive in the environment.

We are also adding a global ID to subareas to make them easier to manage across envs.

To compare subareas across envs , we use the name and their "parent" park. It was verified using a separate script that no 2 subareas have the same name and the same parent park in any env.
So, if 2 subareas in different environments have the same name and same "parent" park, we can be sure that the objects refer to the same subarea.

All comparisons rely on the "parent" park of the subareas. Basically, the pseudocode would be 2 parts.

for envData in envs:
    subareas = envData.subareas
    for subarea in subareas:
        equivalentProdSubarea = findProdSubarea(subarea.park.orcs, subarea.name)
        
        if equivalentProdSubarea:
            subarea.globalId = `{orcs}_{equivalentProdSubarea.id}`
        else:
            subarea.isActive = False    
for subarea in prodSubareas:
    for envData in envs:
        equivalentEnvSubarea = findEnvSubarea(subarea.park.orcs, subarea.name)
        
        if not equivalentEnvSubarea:
            // use prod subarea as template
            createSubareaInEnv(subarea)

The actual code is different but it's the same idea.
There are few data structures that make the comparison easier and more efficient.

parksWithSubareas:

{
    envName: {
         orcs: {
             id, name, subareas: [ { id, name, subareaTypeId } ]
         }
    }
}
{
    envName: {
      orcs: {
        id: parkId,
        orcs: orcs,
        name: parkName,
        missingInProd: [subareaName],
        missingHere: [subareaName],
        totalInProd: totalSubareasInProd,
        totalHere: totalSubareasHere
      }
  }
{
    envName: {
      orcs: {
        subareaName: subareaId
      }
    }
  }

@diego-oxd diego-oxd marked this pull request as ready for review January 28, 2025 23:01
@diego-oxd diego-oxd requested a review from duncan-oxd January 28, 2025 23:01
Copy link
Collaborator

@duncan-oxd duncan-oxd left a comment

Choose a reason for hiding this comment

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

Looks great! If we only need to run this once and we don't need to run it on the environments themselves then we don't have to merge it, but maybe don't delete the branch for a while, just in case 👼

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.

2 participants