Skip to content

Commit

Permalink
fix: create org bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
wwills2 committed Jan 3, 2025
1 parent 4c46054 commit ef6c829
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/models/organizations/organizations.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ class Organization extends Model {
await Promise.all([
Organization.create({
orgUid: newOrganizationId,
registryId: dataModelVersionStoreId,
dataModelVersionStoreId,
registryId: registryStoreId,
isHome: true,
subscribed: USE_SIMULATOR,
fileStoreId,
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/sync-registries.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ const syncOrganizationAudit = async (organization) => {
mirrorTransaction,
});
} else if (diff.type === 'DELETE') {
logger.info(`DELETING: ${modelKey} - ${primaryKeyValue}`);
logger.verbose(`DELETING: ${modelKey} - ${primaryKeyValue}`);
await ModelKeys[modelKey].destroy({
where: {
[ModelKeys[modelKey].primaryKeyAttributes[0]]:
Expand Down
40 changes: 21 additions & 19 deletions src/tasks/validate-organization-table-and-subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,31 @@ const task = new Task('validate-organization-table', async () => {
);

for (const organization of organizations) {
// this is in the loop to prevent this task from trying to operate on an organization that was deleted while it was running
const deletedOrganizations = await Meta.getUserDeletedOrgUids();
if (deletedOrganizations?.includes(organization.orgUid)) {
continue;
}
if (organization.orgUid !== 'PENDING') {
// this is in the loop to prevent this task from trying to operate on an organization that was deleted while it was running
const deletedOrganizations = await Meta.getUserDeletedOrgUids();
if (deletedOrganizations?.includes(organization.orgUid)) {
continue;
}

if (organization.subscribed) {
logger.verbose(
`running the organization reconciliation process for ${organization.name} (orgUid ${organization.orgUid})`,
);
if (organization.subscribed) {
logger.verbose(
`running the organization reconciliation process for ${organization.name} (orgUid ${organization.orgUid})`,
);

try {
await Organization.reconcileOrganization(organization);
} catch (error) {
logger.error(
`failed reconcile organization records and subscriptions for organization ${organization.orgUid}. Error: ${error.message}. `,
try {
await Organization.reconcileOrganization(organization);
} catch (error) {
logger.error(
`failed reconcile organization records and subscriptions for organization ${organization.orgUid}. Error: ${error.message}. `,
);
}
} else {
logger.info(
`organization ${organization.orgUid} is marked as unsubscribed. ensuring all organization stores are unsubscribed`,
);
await Organization.unsubscribeFromOrganizationStores(organization);
}
} else {
logger.info(
`organization ${organization.orgUid} is marked as unsubscribed. ensuring all organization stores are unsubscribed`,
);
await Organization.unsubscribeFromOrganizationStores(organization);
}
}
}
Expand Down

0 comments on commit ef6c829

Please sign in to comment.