Skip to content

Commit

Permalink
refactor: Improve handling of status page resources in subscriber report
Browse files Browse the repository at this point in the history
This commit refactors the code related to the status page subscriber report. The changes include updating the email template and resource handling in the `StatusPageSubscriberReport.hbs` file. The resource table is now rendered based on whether there are any resources to display. If there are no resources, a message indicating the absence of resources is shown.

Additionally, the `SendReportsToSubscribers.ts` file in the `Workers/Jobs/StatusPage` directory has been modified to handle the case where there are no status page resources. If there are no resources, the email report is not sent, and an error is logged.

These changes improve the handling of resources in the status page subscriber report and ensure that the email report is only sent when there are resources to include.
  • Loading branch information
simlarsen committed Jul 25, 2024
1 parent 5c69710 commit 1ed2548
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ RunCron(
"StatusPage:SendReportToSubscribers",
{ schedule: EVERY_MINUTE, runOnStartup: false },
async () => {
debugger;
// get all scheduled events of all the projects.
const statusPageToSendReports: Array<StatusPage> =
await StatusPageService.findBy({
Expand Down
18 changes: 9 additions & 9 deletions CommonServer/Services/StatusPageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,15 +756,15 @@ export class Service extends DatabaseService<StatusPage> {
statusPageId: data.statusPageId,
});

if(statusPageResources.length === 0) {
return {
totalResources: 0,
totalIncidents: 0,
averageUptimePercent: "0%",
totalDowntimeInHoursAndMinutes: "0",
resources: [],
};
}
if (statusPageResources.length === 0) {
return {
totalResources: 0,
totalIncidents: 0,
averageUptimePercent: "0%",
totalDowntimeInHoursAndMinutes: "0",
resources: [],
};
}

const incidentCount: number = await this.getIncidentCountOnStatusPage({
statusPageId: data.statusPageId,
Expand Down

0 comments on commit 1ed2548

Please sign in to comment.