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

optimizes how components are updated when setting the status to "cancelled" #357

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion api/src/reconciliation/reconciliation.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export class ReconciliationController {
const terminationRequests = waitingWorkflows.map((w) =>
TerminateWorkflow(org, w.lastWorkflowRunId)
);
const resp = await Promise.allSettled(terminationRequests);
const resp = await Promise.allSettled(terminationRequests);
const failedResps = resp.filter((r) => r.status === 'rejected');
if (failedResps.length > 0) {
this.logger.error({
Expand All @@ -417,6 +417,17 @@ export class ReconciliationController {
}));

await this.reconSvc.bulkUpdateCompRecon(compReconUpdates);


const components = await this.compSvc.getAllForEnvironmentById(org, envRecon.environment);
const updateComponents = components.map(comp => {
delete comp.latestCompRecon;
const date = new Date().toISOString();
comp.lastReconcileDatetime = date;
return comp;
});
await this.compSvc.bulkUpdate(updateComponents);

delete envRecon.componentReconciles;
await this.reconSvc.updateEnvRecon(envRecon, {
status: 'cancelled',
Expand Down
6 changes: 6 additions & 0 deletions api/src/stream/stream.comp-reconcile.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export class StreamComponentReconcileService
this.eventColumns.has(col.propertyName)
)
) {
if (
event.updatedColumns.find((col) => col.propertyName === 'status') &&
['waiting_for_parent', 'cancelled'].includes(compRecon.status)
) {
return;
}
if (
event.updatedColumns.find((col) => col.propertyName === 'estimatedCost')
) {
Expand Down
4 changes: 3 additions & 1 deletion web/src/auth/AuthStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class AuthStore {
};
}
// Updating user and selected org.
LocalStorage.setItem(LocalStorageKey.SELECTED_ORG, this.user?.selectedOrg);
if (this.user?.selectedOrg) {
LocalStorage.setItem(LocalStorageKey.SELECTED_ORG, this.user?.selectedOrg);
}
LocalStorage.setItem(LocalStorageKey.USER, this.user);
}
}
Expand Down
2 changes: 1 addition & 1 deletion web/src/services/auth/AuthMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class AuthMapper {
...response,
data: {
...response.data,
name: response.data.name,
name: response.data?.name,
},
};
}
Expand Down