mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
style: improve code formatting and readability in various services
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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<Model> {
|
||||
|
||||
// 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<Model> {
|
||||
feedInfoInMarkdown: feedInfoInMarkdown,
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`Error in executeEpisodeOnCallDutyPoliciesAsync: ${error}`,
|
||||
);
|
||||
logger.error(`Error in executeEpisodeOnCallDutyPoliciesAsync: ${error}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,7 +348,8 @@ export class Service extends DatabaseService<Model> {
|
||||
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()})`;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,8 @@ export class Service extends DatabaseService<Model> {
|
||||
}
|
||||
|
||||
if (options.triggeredByAlertEpisodeId) {
|
||||
logTimelineItem.triggeredByAlertEpisodeId = options.triggeredByAlertEpisodeId;
|
||||
logTimelineItem.triggeredByAlertEpisodeId =
|
||||
options.triggeredByAlertEpisodeId;
|
||||
}
|
||||
|
||||
if (options.onCallDutyPolicyExecutionLogTimelineId) {
|
||||
@@ -308,7 +309,9 @@ export class Service extends DatabaseService<Model> {
|
||||
}
|
||||
|
||||
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<Model> {
|
||||
).toString()
|
||||
: acknowledgeUrl.toString();
|
||||
|
||||
const templateKey: WhatsAppTemplateId = WhatsAppTemplateIds.AlertEpisodeCreated;
|
||||
const templateKey: WhatsAppTemplateId =
|
||||
WhatsAppTemplateIds.AlertEpisodeCreated;
|
||||
const templateVariables: Record<string, string> = {
|
||||
project_name: alertEpisode.project?.name || "OneUptime",
|
||||
episode_title: alertEpisode.title || "",
|
||||
@@ -1793,7 +1797,8 @@ export class Service extends DatabaseService<Model> {
|
||||
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<Model> {
|
||||
}
|
||||
|
||||
if (options.triggeredByAlertEpisodeId) {
|
||||
userOnCallLog.triggeredByAlertEpisodeId = options.triggeredByAlertEpisodeId;
|
||||
userOnCallLog.triggeredByAlertEpisodeId =
|
||||
options.triggeredByAlertEpisodeId;
|
||||
}
|
||||
|
||||
userOnCallLog.userNotificationEventType = options.userNotificationEventType;
|
||||
|
||||
Reference in New Issue
Block a user