Skip to content

Commit

Permalink
refactor: improve code readability in StatusPageAPI and Overview comp…
Browse files Browse the repository at this point in the history
…onents
  • Loading branch information
simlarsen committed Jan 10, 2025
1 parent 15e49c1 commit 5ebcba9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
17 changes: 10 additions & 7 deletions Common/Server/API/StatusPageAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ export default class StatusPageAPI extends BaseAPI<
statusPageResources.find((resource: StatusPageResource) => {
return (
resource.monitorGroupId?.toString() ===
monitorGroupId.toString() &&
monitorGroupId.toString() &&
(resource.showStatusHistoryChart ||
resource.showUptimePercent)
);
Expand Down Expand Up @@ -1093,12 +1093,17 @@ export default class StatusPageAPI extends BaseAPI<
},
});


const overallStatus: MonitorStatus | null = this.getOverallMonitorStatus(statusPageResources, monitorStatuses, monitorGroupCurrentStatuses);
const overallStatus: MonitorStatus | null =
this.getOverallMonitorStatus(
statusPageResources,
monitorStatuses,
monitorGroupCurrentStatuses,
);

const response: JSONObject = {

overallStatus: overallStatus ? BaseModel.toJSON(overallStatus, MonitorStatus) : null,
overallStatus: overallStatus
? BaseModel.toJSON(overallStatus, MonitorStatus)
: null,

scheduledMaintenanceEventsPublicNotes: BaseModel.toJSONArray(
scheduledMaintenanceEventsPublicNotes,
Expand Down Expand Up @@ -2291,7 +2296,6 @@ export default class StatusPageAPI extends BaseAPI<
return response;
}


public getOverallMonitorStatus(
statusPageResources: Array<StatusPageResource>,
monitorStatuses: Array<MonitorStatus>,
Expand Down Expand Up @@ -2341,5 +2345,4 @@ export default class StatusPageAPI extends BaseAPI<

return currentStatus;
}

}
15 changes: 7 additions & 8 deletions StatusPage/src/Pages/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,15 @@ const Overview: FunctionComponent<PageComponentProps> = (
setIncidentStateTimelines(incidentStateTimelines);
setScheduledMaintenanceStateTimelines(scheduledMaintenanceStateTimelines);

const overallStatus: MonitorStatus | null = data["overallStatus"] ? BaseModel.fromJSONObject(
(data["overallStatus"] as JSONObject) || {},
MonitorStatus,
) : null;
const overallStatus: MonitorStatus | null = data["overallStatus"]
? BaseModel.fromJSONObject(
(data["overallStatus"] as JSONObject) || {},
MonitorStatus,
)
: null;

// Parse Data.
setCurrentStatus(
overallStatus
);
setCurrentStatus(overallStatus);

setIsLoading(false);
props.onLoadComplete();
Expand Down Expand Up @@ -366,7 +366,6 @@ const Overview: FunctionComponent<PageComponentProps> = (
return <></>;
};


if (isLoading) {
return <PageLoader isVisible={true} />;
}
Expand Down
2 changes: 1 addition & 1 deletion Worker/Routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import "./Jobs/StatusPageOwners/SendCreatedResourceNotification";
import "./Jobs/StatusPageOwners/SendOwnerAddedNotification";

// Status Page Reports
// import "./Jobs/StatusPage/SendReportsToSubscribers";
import "./Jobs/StatusPage/SendReportsToSubscribers";

// Telemetry Service
import "./Jobs/TelemetryService/DeleteOldData";
Expand Down

0 comments on commit 5ebcba9

Please sign in to comment.