From 229775935e0854f15e6c8db8cd9bcc314e147678 Mon Sep 17 00:00:00 2001 From: Nawaz Dhandala Date: Mon, 26 Jan 2026 23:22:27 +0000 Subject: [PATCH] style: improve code formatting and readability in various services --- .../DatabaseModels/UserOnCallLogTimeline.ts | 6 ++++-- Common/Server/Services/AlertEpisodeService.ts | 19 +++++++++++++------ .../OnCallDutyPolicyExecutionLogService.ts | 3 ++- .../Services/UserNotificationRuleService.ts | 16 +++++++++++----- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/Common/Models/DatabaseModels/UserOnCallLogTimeline.ts b/Common/Models/DatabaseModels/UserOnCallLogTimeline.ts index 10734c0a3b..9585934e69 100644 --- a/Common/Models/DatabaseModels/UserOnCallLogTimeline.ts +++ b/Common/Models/DatabaseModels/UserOnCallLogTimeline.ts @@ -400,7 +400,8 @@ export default class UserOnCallLogTimeline extends BaseModel { type: TableColumnType.Entity, modelType: AlertEpisode, title: "Alert Episode", - description: "Relation to Alert Episode Resource in which this object belongs", + description: + "Relation to Alert Episode Resource in which this object belongs", }) @ManyToOne( () => { @@ -427,7 +428,8 @@ export default class UserOnCallLogTimeline extends BaseModel { required: false, canReadOnRelationQuery: true, title: "Alert Episode ID", - description: "ID of your OneUptime Alert Episode in which this object belongs", + description: + "ID of your OneUptime Alert Episode in which this object belongs", }) @Column({ type: ColumnType.ObjectID, diff --git a/Common/Server/Services/AlertEpisodeService.ts b/Common/Server/Services/AlertEpisodeService.ts index f735855225..cc29314e90 100644 --- a/Common/Server/Services/AlertEpisodeService.ts +++ b/Common/Server/Services/AlertEpisodeService.ts @@ -18,7 +18,12 @@ import { IsBillingEnabled } from "../EnvironmentConfig"; import OneUptimeDate from "../../Types/Date"; import AlertEpisodeFeedService from "./AlertEpisodeFeedService"; import { AlertEpisodeFeedEventType } from "../../Models/DatabaseModels/AlertEpisodeFeed"; -import { Red500, Green500, Yellow500, Purple500 } from "../../Types/BrandColors"; +import { + Red500, + Green500, + Yellow500, + Purple500, +} from "../../Types/BrandColors"; import URL from "../../Types/API/URL"; import DatabaseConfig from "../DatabaseConfig"; import AlertSeverityService from "./AlertSeverityService"; @@ -312,8 +317,12 @@ export class Service extends DatabaseService { // Create feed entry for on-call policy execution const policyNames: string[] = episodeWithPolicies.onCallDutyPolicies - .map((policy: OnCallDutyPolicy) => policy.name || "Unnamed Policy") - .filter((name: string) => Boolean(name)); + .map((policy: OnCallDutyPolicy) => { + return policy.name || "Unnamed Policy"; + }) + .filter((name: string) => { + return Boolean(name); + }); let feedInfoInMarkdown: string = `#### On-Call Policy Executed\n\n`; feedInfoInMarkdown += `The following on-call ${policyNames.length === 1 ? "policy has" : "policies have"} been executed for this episode:\n\n`; @@ -330,9 +339,7 @@ export class Service extends DatabaseService { feedInfoInMarkdown: feedInfoInMarkdown, }); } catch (error) { - logger.error( - `Error in executeEpisodeOnCallDutyPoliciesAsync: ${error}`, - ); + logger.error(`Error in executeEpisodeOnCallDutyPoliciesAsync: ${error}`); throw error; } } diff --git a/Common/Server/Services/OnCallDutyPolicyExecutionLogService.ts b/Common/Server/Services/OnCallDutyPolicyExecutionLogService.ts index 6cdf79eb62..91a16a3320 100644 --- a/Common/Server/Services/OnCallDutyPolicyExecutionLogService.ts +++ b/Common/Server/Services/OnCallDutyPolicyExecutionLogService.ts @@ -348,7 +348,8 @@ export class Service extends DatabaseService { if (onCalldutyPolicyExecutionLog.triggeredByAlertEpisodeId) { const episodeNumber: number | null = await AlertEpisodeService.getEpisodeNumber({ - episodeId: onCalldutyPolicyExecutionLog.triggeredByAlertEpisodeId, + episodeId: + onCalldutyPolicyExecutionLog.triggeredByAlertEpisodeId, }); incidentOrAlertLink = `[Alert Episode ${episodeNumber}](${(await AlertEpisodeService.getEpisodeLinkInDashboard(onCalldutyPolicyExecutionLog.projectId!, onCalldutyPolicyExecutionLog.triggeredByAlertEpisodeId)).toString()})`; } diff --git a/Common/Server/Services/UserNotificationRuleService.ts b/Common/Server/Services/UserNotificationRuleService.ts index e269fa43c8..eedf4b2292 100644 --- a/Common/Server/Services/UserNotificationRuleService.ts +++ b/Common/Server/Services/UserNotificationRuleService.ts @@ -205,7 +205,8 @@ export class Service extends DatabaseService { } if (options.triggeredByAlertEpisodeId) { - logTimelineItem.triggeredByAlertEpisodeId = options.triggeredByAlertEpisodeId; + logTimelineItem.triggeredByAlertEpisodeId = + options.triggeredByAlertEpisodeId; } if (options.onCallDutyPolicyExecutionLogTimelineId) { @@ -308,7 +309,9 @@ export class Service extends DatabaseService { } if (!incident && !alert && !alertEpisode) { - throw new BadDataException("Incident, Alert, or Alert Episode not found."); + throw new BadDataException( + "Incident, Alert, or Alert Episode not found.", + ); } if ( @@ -1648,7 +1651,8 @@ export class Service extends DatabaseService { ).toString() : acknowledgeUrl.toString(); - const templateKey: WhatsAppTemplateId = WhatsAppTemplateIds.AlertEpisodeCreated; + const templateKey: WhatsAppTemplateId = + WhatsAppTemplateIds.AlertEpisodeCreated; const templateVariables: Record = { project_name: alertEpisode.project?.name || "OneUptime", episode_title: alertEpisode.title || "", @@ -1793,7 +1797,8 @@ export class Service extends DatabaseService { toEmail: to!, templateType: EmailTemplateType.AcknowledgeAlertEpisode, vars: vars, - subject: "ACTION REQUIRED: Alert Episode created - " + alertEpisode.title!, + subject: + "ACTION REQUIRED: Alert Episode created - " + alertEpisode.title!, }; return emailMessage; @@ -1832,7 +1837,8 @@ export class Service extends DatabaseService { } if (options.triggeredByAlertEpisodeId) { - userOnCallLog.triggeredByAlertEpisodeId = options.triggeredByAlertEpisodeId; + userOnCallLog.triggeredByAlertEpisodeId = + options.triggeredByAlertEpisodeId; } userOnCallLog.userNotificationEventType = options.userNotificationEventType;