diff --git a/App/FeatureSet/AdminDashboard/src/Pages/More/Email.tsx b/App/FeatureSet/AdminDashboard/src/Pages/More/Email.tsx index 4278eac06d..e81990348d 100644 --- a/App/FeatureSet/AdminDashboard/src/Pages/More/Email.tsx +++ b/App/FeatureSet/AdminDashboard/src/Pages/More/Email.tsx @@ -133,11 +133,7 @@ const MoreEmail: FunctionComponent = (): ReactElement => { description="Compose an announcement email to send to all registered users. You can send a test email first to preview how it looks." > {success ? ( - + ) : ( <> )} diff --git a/App/FeatureSet/Dashboard/src/Components/Workspace/WorkspaceSummaryTable.tsx b/App/FeatureSet/Dashboard/src/Components/Workspace/WorkspaceSummaryTable.tsx index 2084e9fd6c..acfc9e7757 100644 --- a/App/FeatureSet/Dashboard/src/Components/Workspace/WorkspaceSummaryTable.tsx +++ b/App/FeatureSet/Dashboard/src/Components/Workspace/WorkspaceSummaryTable.tsx @@ -298,10 +298,7 @@ const WorkspaceSummaryTable: FunctionComponent = ( } // Parse channel names from comma-separated string - if ( - values.channelNames && - typeof values.channelNames === "string" - ) { + if (values.channelNames && typeof values.channelNames === "string") { values.channelNames = (values.channelNames as unknown as string) .split(",") .map((name: string) => { @@ -329,11 +326,7 @@ const WorkspaceSummaryTable: FunctionComponent = ( if (values.filters && Array.isArray(values.filters)) { values.filters = values.filters.filter( (f: NotificationRuleCondition) => { - return ( - f.value && - Array.isArray(f.value) && - f.value.length > 0 - ); + return f.value && Array.isArray(f.value) && f.value.length > 0; }, ); } @@ -346,10 +339,7 @@ const WorkspaceSummaryTable: FunctionComponent = ( }} onBeforeEdit={(values: WorkspaceNotificationSummary) => { // Parse channel names from comma-separated string - if ( - values.channelNames && - typeof values.channelNames === "string" - ) { + if (values.channelNames && typeof values.channelNames === "string") { values.channelNames = (values.channelNames as unknown as string) .split(",") .map((name: string) => { @@ -360,8 +350,10 @@ const WorkspaceSummaryTable: FunctionComponent = ( }); } - // If sendFirstReportAt was changed and is in the future, use it as nextSendAt. - // Otherwise leave nextSendAt alone — the worker manages it after the first send. + /* + * If sendFirstReportAt was changed and is in the future, use it as nextSendAt. + * Otherwise leave nextSendAt alone — the worker manages it after the first send. + */ if (values.sendFirstReportAt) { const firstReportDate: Date = new Date( values.sendFirstReportAt as unknown as string, @@ -378,11 +370,7 @@ const WorkspaceSummaryTable: FunctionComponent = ( if (values.filters && Array.isArray(values.filters)) { values.filters = values.filters.filter( (f: NotificationRuleCondition) => { - return ( - f.value && - Array.isArray(f.value) && - f.value.length > 0 - ); + return f.value && Array.isArray(f.value) && f.value.length > 0; }, ); } @@ -460,9 +448,7 @@ const WorkspaceSummaryTable: FunctionComponent = ( initialValue={ value.recurringInterval && value.recurringInterval instanceof Recurring - ? Recurring.fromJSON( - value.recurringInterval as Recurring, - ) + ? Recurring.fromJSON(value.recurringInterval as Recurring) : undefined } /> @@ -555,9 +541,7 @@ const WorkspaceSummaryTable: FunctionComponent = ( incidentStates={incidentStates} scheduledMaintenanceStates={[]} monitorStatus={[]} - onChange={( - conditions: Array, - ) => { + onChange={(conditions: Array) => { if (elementProps.onChange) { elementProps.onChange(conditions); } @@ -628,9 +612,7 @@ const WorkspaceSummaryTable: FunctionComponent = ( }, title: "Frequency", type: FieldType.Element, - getElement: ( - value: WorkspaceNotificationSummary, - ): ReactElement => { + getElement: (value: WorkspaceNotificationSummary): ReactElement => { return ( = ( }, title: "Lookback", type: FieldType.Element, - getElement: ( - value: WorkspaceNotificationSummary, - ): ReactElement => { + getElement: (value: WorkspaceNotificationSummary): ReactElement => { return {value.numberOfDaysOfData} days; }, }, diff --git a/Common/Server/API/WorkspaceNotificationSummaryAPI.ts b/Common/Server/API/WorkspaceNotificationSummaryAPI.ts index f03e77a4cb..3733b5cbb8 100644 --- a/Common/Server/API/WorkspaceNotificationSummaryAPI.ts +++ b/Common/Server/API/WorkspaceNotificationSummaryAPI.ts @@ -19,19 +19,12 @@ export default class WorkspaceNotificationSummaryAPI extends BaseAPI< WorkspaceNotificationSummaryServiceType > { public constructor() { - super( - WorkspaceNotificationSummary, - WorkspaceNotificationSummaryService, - ); + super(WorkspaceNotificationSummary, WorkspaceNotificationSummaryService); this.router.get( `${new this.entityType().getCrudApiPath()?.toString()}/test/:workspaceNotificationSummaryId`, UserMiddleware.getUserMiddleware, - async ( - req: ExpressRequest, - res: ExpressResponse, - next: NextFunction, - ) => { + async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => { try { const databaseProps: DatabaseCommonInteractionProps = await CommonAPI.getDatabaseCommonInteractionProps(req); diff --git a/Common/Server/Infrastructure/Postgres/SchemaMigrations/1774355321449-MigrationName.ts b/Common/Server/Infrastructure/Postgres/SchemaMigrations/1774355321449-MigrationName.ts index 251d3caf29..97bee64c25 100644 --- a/Common/Server/Infrastructure/Postgres/SchemaMigrations/1774355321449-MigrationName.ts +++ b/Common/Server/Infrastructure/Postgres/SchemaMigrations/1774355321449-MigrationName.ts @@ -1,26 +1,51 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class MigrationName1774355321449 implements MigrationInterface { - public name = 'MigrationName1774355321449' + public name = "MigrationName1774355321449"; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "WorkspaceNotificationSummary" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "name" character varying(500) NOT NULL, "description" character varying(500), "workspaceType" character varying(500) NOT NULL, "summaryType" character varying NOT NULL, "recurringInterval" jsonb NOT NULL, "numberOfDaysOfData" integer NOT NULL DEFAULT '7', "channelNames" jsonb NOT NULL, "teamName" character varying(500), "summaryItems" jsonb NOT NULL, "filters" jsonb, "filterCondition" character varying, "nextSendAt" TIMESTAMP WITH TIME ZONE, "lastSentAt" TIMESTAMP WITH TIME ZONE, "isEnabled" boolean NOT NULL DEFAULT true, "createdByUserId" uuid, "deletedByUserId" uuid, CONSTRAINT "PK_c5bb0f644c5279e3781177ce819" PRIMARY KEY ("_id"))`); - await queryRunner.query(`CREATE INDEX "IDX_d7f80977bcbac1b82c2beacc27" ON "WorkspaceNotificationSummary" ("projectId") `); - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`); - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`); - await queryRunner.query(`ALTER TABLE "WorkspaceNotificationSummary" ADD CONSTRAINT "FK_d7f80977bcbac1b82c2beacc271" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "WorkspaceNotificationSummary" ADD CONSTRAINT "FK_f9c24022445dbea5d8b2d104302" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "WorkspaceNotificationSummary" ADD CONSTRAINT "FK_a9f1c0c0d88abf1795d1c93c138" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "WorkspaceNotificationSummary" DROP CONSTRAINT "FK_a9f1c0c0d88abf1795d1c93c138"`); - await queryRunner.query(`ALTER TABLE "WorkspaceNotificationSummary" DROP CONSTRAINT "FK_f9c24022445dbea5d8b2d104302"`); - await queryRunner.query(`ALTER TABLE "WorkspaceNotificationSummary" DROP CONSTRAINT "FK_d7f80977bcbac1b82c2beacc271"`); - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`); - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`); - await queryRunner.query(`DROP INDEX "public"."IDX_d7f80977bcbac1b82c2beacc27"`); - await queryRunner.query(`DROP TABLE "WorkspaceNotificationSummary"`); - } + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE "WorkspaceNotificationSummary" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "name" character varying(500) NOT NULL, "description" character varying(500), "workspaceType" character varying(500) NOT NULL, "summaryType" character varying NOT NULL, "recurringInterval" jsonb NOT NULL, "numberOfDaysOfData" integer NOT NULL DEFAULT '7', "channelNames" jsonb NOT NULL, "teamName" character varying(500), "summaryItems" jsonb NOT NULL, "filters" jsonb, "filterCondition" character varying, "nextSendAt" TIMESTAMP WITH TIME ZONE, "lastSentAt" TIMESTAMP WITH TIME ZONE, "isEnabled" boolean NOT NULL DEFAULT true, "createdByUserId" uuid, "deletedByUserId" uuid, CONSTRAINT "PK_c5bb0f644c5279e3781177ce819" PRIMARY KEY ("_id"))`, + ); + await queryRunner.query( + `CREATE INDEX "IDX_d7f80977bcbac1b82c2beacc27" ON "WorkspaceNotificationSummary" ("projectId") `, + ); + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`, + ); + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`, + ); + await queryRunner.query( + `ALTER TABLE "WorkspaceNotificationSummary" ADD CONSTRAINT "FK_d7f80977bcbac1b82c2beacc271" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "WorkspaceNotificationSummary" ADD CONSTRAINT "FK_f9c24022445dbea5d8b2d104302" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "WorkspaceNotificationSummary" ADD CONSTRAINT "FK_a9f1c0c0d88abf1795d1c93c138" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`, + ); + } + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "WorkspaceNotificationSummary" DROP CONSTRAINT "FK_a9f1c0c0d88abf1795d1c93c138"`, + ); + await queryRunner.query( + `ALTER TABLE "WorkspaceNotificationSummary" DROP CONSTRAINT "FK_f9c24022445dbea5d8b2d104302"`, + ); + await queryRunner.query( + `ALTER TABLE "WorkspaceNotificationSummary" DROP CONSTRAINT "FK_d7f80977bcbac1b82c2beacc271"`, + ); + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`, + ); + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`, + ); + await queryRunner.query( + `DROP INDEX "public"."IDX_d7f80977bcbac1b82c2beacc27"`, + ); + await queryRunner.query(`DROP TABLE "WorkspaceNotificationSummary"`); + } } diff --git a/Common/Server/Infrastructure/Postgres/SchemaMigrations/1774357353502-MigrationName.ts b/Common/Server/Infrastructure/Postgres/SchemaMigrations/1774357353502-MigrationName.ts index 0c0c1e4677..a08778fcfb 100644 --- a/Common/Server/Infrastructure/Postgres/SchemaMigrations/1774357353502-MigrationName.ts +++ b/Common/Server/Infrastructure/Postgres/SchemaMigrations/1774357353502-MigrationName.ts @@ -1,18 +1,29 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class MigrationName1774357353502 implements MigrationInterface { - name = 'MigrationName1774357353502' + name = "MigrationName1774357353502"; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "WorkspaceNotificationSummary" ADD "sendFirstReportAt" TIMESTAMP WITH TIME ZONE`); - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`); - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`); - await queryRunner.query(`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`); - await queryRunner.query(`ALTER TABLE "WorkspaceNotificationSummary" DROP COLUMN "sendFirstReportAt"`); - } + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "WorkspaceNotificationSummary" ADD "sendFirstReportAt" TIMESTAMP WITH TIME ZONE`, + ); + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`, + ); + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`, + ); + } + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`, + ); + await queryRunner.query( + `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`, + ); + await queryRunner.query( + `ALTER TABLE "WorkspaceNotificationSummary" DROP COLUMN "sendFirstReportAt"`, + ); + } } diff --git a/Common/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts b/Common/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts index a3f597f123..38f37cdf54 100644 --- a/Common/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +++ b/Common/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts @@ -543,5 +543,5 @@ export default [ MigrationName1774000000000, MigrationName1774000000001, MigrationName1774355321449, - MigrationName1774357353502 + MigrationName1774357353502, ]; diff --git a/Common/Server/Middleware/MasterAdminAuthorization.ts b/Common/Server/Middleware/MasterAdminAuthorization.ts index 15acb5c772..b88e305a31 100644 --- a/Common/Server/Middleware/MasterAdminAuthorization.ts +++ b/Common/Server/Middleware/MasterAdminAuthorization.ts @@ -23,9 +23,7 @@ export default class MasterAdminAuthorization { Response.sendErrorResponse( req, res, - new NotAuthorizedException( - "Unauthorized: Access token is required.", - ), + new NotAuthorizedException("Unauthorized: Access token is required."), ); return; } diff --git a/Common/Server/Services/WorkspaceNotificationSummaryService.ts b/Common/Server/Services/WorkspaceNotificationSummaryService.ts index 478f03bd0c..d65724b798 100644 --- a/Common/Server/Services/WorkspaceNotificationSummaryService.ts +++ b/Common/Server/Services/WorkspaceNotificationSummaryService.ts @@ -37,12 +37,14 @@ import FilterCondition from "../../Types/Filter/FilterCondition"; import { WorkspaceNotificationRuleUtil } from "../../Types/Workspace/NotificationRules/NotificationRuleUtil"; import IncidentNotificationRule from "../../Types/Workspace/NotificationRules/NotificationRuleTypes/IncidentNotificationRule"; -// NOTE ON FORMATTING: -// WorkspacePayloadMarkdown text goes through SlackifyMarkdown which converts -// standard markdown to Slack mrkdwn. So we must use: -// **bold** (NOT *bold*) -// _italic_ (same in both) -// [text](url) (NOT ) +/* + * NOTE ON FORMATTING: + * WorkspacePayloadMarkdown text goes through SlackifyMarkdown which converts + * standard markdown to Slack mrkdwn. So we must use: + * **bold** (NOT *bold*) + * _italic_ (same in both) + * [text](url) (NOT ) + */ interface TimelineData { ackBy?: string | undefined; @@ -72,8 +74,8 @@ export class Service extends DatabaseService { summaryId: ObjectID; isTest?: boolean; }): Promise { - const summary: WorkspaceNotificationSummary | null = - await this.findOneById({ + const summary: WorkspaceNotificationSummary | null = await this.findOneById( + { id: data.summaryId, select: { projectId: true, @@ -91,7 +93,8 @@ export class Service extends DatabaseService { props: { isRoot: true, }, - }); + }, + ); if (!summary) { throw new BadDataException("Summary not found"); @@ -227,8 +230,7 @@ export class Service extends DatabaseService { | undefined; } { return { - [NotificationRuleConditionCheckOn.IncidentTitle]: - incident.title || "", + [NotificationRuleConditionCheckOn.IncidentTitle]: incident.title || "", [NotificationRuleConditionCheckOn.IncidentDescription]: incident.description || "", [NotificationRuleConditionCheckOn.IncidentSeverity]: @@ -259,8 +261,7 @@ export class Service extends DatabaseService { [NotificationRuleConditionCheckOn.ScheduledMaintenanceLabels]: undefined, [NotificationRuleConditionCheckOn.MonitorLabels]: undefined, [NotificationRuleConditionCheckOn.OnCallDutyPolicyName]: undefined, - [NotificationRuleConditionCheckOn.OnCallDutyPolicyDescription]: - undefined, + [NotificationRuleConditionCheckOn.OnCallDutyPolicyDescription]: undefined, [NotificationRuleConditionCheckOn.OnCallDutyPolicyLabels]: undefined, [NotificationRuleConditionCheckOn.AlertEpisodeTitle]: undefined, [NotificationRuleConditionCheckOn.AlertEpisodeDescription]: undefined, @@ -313,8 +314,7 @@ export class Service extends DatabaseService { [NotificationRuleConditionCheckOn.ScheduledMaintenanceLabels]: undefined, [NotificationRuleConditionCheckOn.MonitorLabels]: undefined, [NotificationRuleConditionCheckOn.OnCallDutyPolicyName]: undefined, - [NotificationRuleConditionCheckOn.OnCallDutyPolicyDescription]: - undefined, + [NotificationRuleConditionCheckOn.OnCallDutyPolicyDescription]: undefined, [NotificationRuleConditionCheckOn.OnCallDutyPolicyLabels]: undefined, [NotificationRuleConditionCheckOn.AlertEpisodeTitle]: undefined, [NotificationRuleConditionCheckOn.AlertEpisodeDescription]: undefined, @@ -354,9 +354,7 @@ export class Service extends DatabaseService { // Title blocks.push( - Service.header( - `${type} Summary — ${fromDateStr} to ${toDateStr}`, - ), + Service.header(`${type} Summary — ${fromDateStr} to ${toDateStr}`), ); blocks.push( @@ -396,9 +394,7 @@ export class Service extends DatabaseService { // Footer blocks.push(Service.divider()); blocks.push( - Service.md( - `_Sent by OneUptime • ${summary.name || "Untitled"}_`, - ), + Service.md(`_Sent by OneUptime • ${summary.name || "Untitled"}_`), ); return blocks; @@ -635,9 +631,7 @@ export class Service extends DatabaseService { blocks.push(Service.divider()); if (incidents.length === 0) { - blocks.push( - Service.md(`_No incidents reported in this period._`), - ); + blocks.push(Service.md(`_No incidents reported in this period._`)); return; } @@ -681,9 +675,7 @@ export class Service extends DatabaseService { ackResolve.push(`_Not yet acknowledged_`); } } - if ( - Service.has(items, WorkspaceNotificationSummaryItem.WhoResolved) - ) { + if (Service.has(items, WorkspaceNotificationSummaryItem.WhoResolved)) { if (td?.resolvedBy && td?.resolvedAt) { ackResolve.push( `Resolved: ${Service.bold(td.resolvedBy)} in ${Service.formatDuration(OneUptimeDate.getMinutesBetweenTwoDates(td.declaredAt || inc.createdAt!, td.resolvedAt))}`, @@ -725,7 +717,11 @@ export class Service extends DatabaseService { title: true, description: true, incidentSeverity: { name: true, _id: true }, - currentIncidentState: { name: true, _id: true, isResolvedState: true }, + currentIncidentState: { + name: true, + _id: true, + isResolvedState: true, + }, createdAt: true, resolvedAt: true, }, @@ -807,9 +803,7 @@ export class Service extends DatabaseService { blocks.push(Service.divider()); if (episodes.length === 0) { - blocks.push( - Service.md(`_No incident episodes in this period._`), - ); + blocks.push(Service.md(`_No incident episodes in this period._`)); return; } @@ -1098,9 +1092,7 @@ export class Service extends DatabaseService { ackResolve.push(`_Not yet acknowledged_`); } } - if ( - Service.has(items, WorkspaceNotificationSummaryItem.WhoResolved) - ) { + if (Service.has(items, WorkspaceNotificationSummaryItem.WhoResolved)) { if (td?.resolvedBy && td?.resolvedAt) { ackResolve.push( `Resolved: ${Service.bold(td.resolvedBy)} in ${Service.formatDuration(OneUptimeDate.getMinutesBetweenTwoDates(td.declaredAt || a.createdAt!, td.resolvedAt))}`, @@ -1131,23 +1123,22 @@ export class Service extends DatabaseService { }): Promise { const { blocks, items, fromDate, projectId } = data; - const episodes: Array = - await AlertEpisodeService.findAllBy({ - query: { - projectId, - createdAt: QueryHelper.greaterThanEqualTo(fromDate), - }, - select: { - _id: true, - title: true, - description: true, - alertSeverity: { name: true, _id: true }, - currentAlertState: { name: true, _id: true, isResolvedState: true }, - createdAt: true, - resolvedAt: true, - }, - props: { isRoot: true }, - }); + const episodes: Array = await AlertEpisodeService.findAllBy({ + query: { + projectId, + createdAt: QueryHelper.greaterThanEqualTo(fromDate), + }, + select: { + _id: true, + title: true, + description: true, + alertSeverity: { name: true, _id: true }, + currentAlertState: { name: true, _id: true, isResolvedState: true }, + createdAt: true, + resolvedAt: true, + }, + props: { isRoot: true }, + }); const dashboardUrl: URL = await DatabaseConfig.getDashboardUrl(); @@ -1224,9 +1215,7 @@ export class Service extends DatabaseService { blocks.push(Service.divider()); if (episodes.length === 0) { - blocks.push( - Service.md(`_No alert episodes in this period._`), - ); + blocks.push(Service.md(`_No alert episodes in this period._`)); return; }