Skip to content

Commit 886cf17

Browse files
committed
fix: add missing commas for better code readability in OnCallDutyPolicyEscalationRuleService and OnCallDutyPolicyScheduleService
1 parent 526475d commit 886cf17

File tree

3 files changed

+42
-39
lines changed

3 files changed

+42
-39
lines changed

Common/Server/Services/OnCallDutyPolicyEscalationRuleService.ts

+36-36
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class Service extends DatabaseService<Model> {
4343
projectId: ObjectID;
4444
}): Promise<ObjectID | null> {
4545
logger.debug(
46-
`Getting route alert to user id for userId: ${data.userId.toString()}`
46+
`Getting route alert to user id for userId: ${data.userId.toString()}`,
4747
);
4848

4949
const currentDate: Date = OneUptimeDate.getCurrentDate();
@@ -53,7 +53,7 @@ export class Service extends DatabaseService<Model> {
5353
query: {
5454
overrideUserId: data.userId,
5555
onCallDutyPolicyId: QueryHelper.equalToOrNull(
56-
data.onCallDutyPolicyId
56+
data.onCallDutyPolicyId,
5757
), // find global overrides as well. If this is null, then it will find global overrides.
5858
projectId: data.projectId,
5959
startsAt: QueryHelper.lessThanEqualTo(currentDate),
@@ -83,7 +83,7 @@ export class Service extends DatabaseService<Model> {
8383

8484
if (localOverride && localOverride.routeAlertsToUserId) {
8585
logger.debug(
86-
`Route alert to user id found: ${localOverride.routeAlertsToUserId.toString()}`
86+
`Route alert to user id found: ${localOverride.routeAlertsToUserId.toString()}`,
8787
);
8888
return localOverride.routeAlertsToUserId;
8989
}
@@ -95,7 +95,7 @@ export class Service extends DatabaseService<Model> {
9595

9696
if (globalOverride && globalOverride.routeAlertsToUserId) {
9797
logger.debug(
98-
`Route alert to user id found: ${globalOverride.routeAlertsToUserId.toString()}`
98+
`Route alert to user id found: ${globalOverride.routeAlertsToUserId.toString()}`,
9999
);
100100
return globalOverride.routeAlertsToUserId;
101101
}
@@ -113,7 +113,7 @@ export class Service extends DatabaseService<Model> {
113113
userNotificationEventType: UserNotificationEventType;
114114
onCallPolicyExecutionLogId: ObjectID;
115115
onCallPolicyId: ObjectID;
116-
}
116+
},
117117
): Promise<void> {
118118
logger.debug(`Starting rule execution for ruleId: ${ruleId.toString()}`);
119119

@@ -131,7 +131,7 @@ export class Service extends DatabaseService<Model> {
131131

132132
if (!rule) {
133133
throw new BadDataException(
134-
`On-Call Duty Policy Escalation Rule with id ${ruleId.toString()} not found`
134+
`On-Call Duty Policy Escalation Rule with id ${ruleId.toString()} not found`,
135135
);
136136
}
137137

@@ -182,7 +182,7 @@ export class Service extends DatabaseService<Model> {
182182
!options.triggeredByIncidentId
183183
) {
184184
throw new BadDataException(
185-
"triggeredByIncidentId is required when userNotificationEventType is IncidentCreated"
185+
"triggeredByIncidentId is required when userNotificationEventType is IncidentCreated",
186186
);
187187
}
188188

@@ -192,7 +192,7 @@ export class Service extends DatabaseService<Model> {
192192
!options.triggeredByAlertId
193193
) {
194194
throw new BadDataException(
195-
"triggeredByAlertId is required when userNotificationEventType is IncidentCreated"
195+
"triggeredByAlertId is required when userNotificationEventType is IncidentCreated",
196196
);
197197
}
198198

@@ -250,14 +250,14 @@ export class Service extends DatabaseService<Model> {
250250
type StartUserNotificationRuleExecutionFunction = (
251251
userId: ObjectID,
252252
teamId: ObjectID | null,
253-
scheduleId: ObjectID | null
253+
scheduleId: ObjectID | null,
254254
) => Promise<void>;
255255

256256
const startUserNotificationRuleExecution: StartUserNotificationRuleExecutionFunction =
257257
async (
258258
userId: ObjectID,
259259
teamId: ObjectID | null,
260-
scheduleId: ObjectID | null
260+
scheduleId: ObjectID | null,
261261
): Promise<void> => {
262262
// This is where user is notified.
263263

@@ -275,7 +275,7 @@ export class Service extends DatabaseService<Model> {
275275
const alertSentToUserId: ObjectID = routeAlertToUserId || userId;
276276

277277
logger.debug(
278-
`Starting notification rule execution for userId: ${alertSentToUserId.toString()}`
278+
`Starting notification rule execution for userId: ${alertSentToUserId.toString()}`,
279279
);
280280
let log: OnCallDutyPolicyExecutionLogTimeline = getNewLog();
281281
log.statusMessage = "Sending notification to user.";
@@ -315,15 +315,15 @@ export class Service extends DatabaseService<Model> {
315315
projectId: options.projectId,
316316
onCallScheduleId: scheduleId || undefined,
317317
overridedByUserId: routeAlertToUserId ? userId : undefined,
318-
}
318+
},
319319
);
320320
};
321321

322322
const uniqueUserIds: Array<ObjectID> = [];
323323

324324
for (const teamInRule of teamsInRule) {
325325
const usersInTeam: Array<User> = await TeamMemberService.getUsersInTeam(
326-
teamInRule.teamId!
326+
teamInRule.teamId!,
327327
);
328328

329329
for (const user of usersInTeam) {
@@ -336,7 +336,7 @@ export class Service extends DatabaseService<Model> {
336336
await startUserNotificationRuleExecution(
337337
user.id!,
338338
teamInRule.teamId!,
339-
null
339+
null,
340340
);
341341
} else {
342342
const log: OnCallDutyPolicyExecutionLogTimeline = getNewLog();
@@ -383,7 +383,7 @@ export class Service extends DatabaseService<Model> {
383383
for (const scheduleRule of schedulesInRule) {
384384
const userIdInSchedule: ObjectID | null =
385385
await OnCallDutyPolicyScheduleService.getCurrentUserIdInSchedule(
386-
scheduleRule.onCallDutyPolicyScheduleId!
386+
scheduleRule.onCallDutyPolicyScheduleId!,
387387
);
388388

389389
if (!userIdInSchedule) {
@@ -412,7 +412,7 @@ export class Service extends DatabaseService<Model> {
412412
await startUserNotificationRuleExecution(
413413
userIdInSchedule,
414414
null,
415-
scheduleRule.onCallDutyPolicyScheduleId!
415+
scheduleRule.onCallDutyPolicyScheduleId!,
416416
);
417417
} else {
418418
const log: OnCallDutyPolicyExecutionLogTimeline = getNewLog();
@@ -454,7 +454,7 @@ export class Service extends DatabaseService<Model> {
454454
@CaptureSpan()
455455
protected override async onCreateSuccess(
456456
onCreate: OnCreate<Model>,
457-
createdItem: Model
457+
createdItem: Model,
458458
): Promise<Model> {
459459
if (!createdItem.projectId) {
460460
throw new BadDataException("projectId is required");
@@ -481,7 +481,7 @@ export class Service extends DatabaseService<Model> {
481481
(onCreate.createBy.miscDataProps[
482482
"onCallSchedules"
483483
] as Array<ObjectID>) || [],
484-
onCreate.createBy.props
484+
onCreate.createBy.props,
485485
);
486486
}
487487

@@ -496,15 +496,15 @@ export class Service extends DatabaseService<Model> {
496496
usersIds: Array<ObjectID>,
497497
teamIds: Array<ObjectID>,
498498
onCallScheduleIds: Array<ObjectID>,
499-
props: DatabaseCommonInteractionProps
499+
props: DatabaseCommonInteractionProps,
500500
): Promise<void> {
501501
for (const userId of usersIds) {
502502
await this.addUser(
503503
projectId,
504504
escalationRuleId,
505505
onCallDutyPolicyId,
506506
userId,
507-
props
507+
props,
508508
);
509509
}
510510

@@ -514,7 +514,7 @@ export class Service extends DatabaseService<Model> {
514514
escalationRuleId,
515515
onCallDutyPolicyId,
516516
teamId,
517-
props
517+
props,
518518
);
519519
}
520520

@@ -524,7 +524,7 @@ export class Service extends DatabaseService<Model> {
524524
escalationRuleId,
525525
onCallDutyPolicyId,
526526
scheduleId,
527-
props
527+
props,
528528
);
529529
}
530530
}
@@ -535,7 +535,7 @@ export class Service extends DatabaseService<Model> {
535535
escalationRuleId: ObjectID,
536536
onCallDutyPolicyId: ObjectID,
537537
teamId: ObjectID,
538-
props: DatabaseCommonInteractionProps
538+
props: DatabaseCommonInteractionProps,
539539
): Promise<void> {
540540
const teamInRule: OnCallDutyPolicyEscalationRuleTeam =
541541
new OnCallDutyPolicyEscalationRuleTeam();
@@ -556,7 +556,7 @@ export class Service extends DatabaseService<Model> {
556556
escalationRuleId: ObjectID,
557557
onCallDutyPolicyId: ObjectID,
558558
onCallScheduleId: ObjectID,
559-
props: DatabaseCommonInteractionProps
559+
props: DatabaseCommonInteractionProps,
560560
): Promise<void> {
561561
const scheduleInRule: OnCallDutyPolicyEscalationRuleSchedule =
562562
new OnCallDutyPolicyEscalationRuleSchedule();
@@ -577,7 +577,7 @@ export class Service extends DatabaseService<Model> {
577577
escalationRuleId: ObjectID,
578578
onCallDutyPolicyId: ObjectID,
579579
userId: ObjectID,
580-
props: DatabaseCommonInteractionProps
580+
props: DatabaseCommonInteractionProps,
581581
): Promise<void> {
582582
const userInRule: OnCallDutyPolicyEscalationRuleUser =
583583
new OnCallDutyPolicyEscalationRuleUser();
@@ -594,7 +594,7 @@ export class Service extends DatabaseService<Model> {
594594

595595
@CaptureSpan()
596596
protected override async onBeforeCreate(
597-
createBy: CreateBy<Model>
597+
createBy: CreateBy<Model>,
598598
): Promise<OnCreate<Model>> {
599599
if (IsBillingEnabled && createBy.props.currentPlan === PlanType.Free) {
600600
// then check no of policies and if it is more than one, return error
@@ -612,14 +612,14 @@ export class Service extends DatabaseService<Model> {
612612

613613
if (count.toNumber() >= 1) {
614614
throw new BadDataException(
615-
"You can only create one escalation rule in free plan."
615+
"You can only create one escalation rule in free plan.",
616616
);
617617
}
618618
}
619619

620620
if (!createBy.data.onCallDutyPolicyId) {
621621
throw new BadDataException(
622-
"Status Page Resource onCallDutyPolicyId is required"
622+
"Status Page Resource onCallDutyPolicyId is required",
623623
);
624624
}
625625

@@ -641,7 +641,7 @@ export class Service extends DatabaseService<Model> {
641641
await this.rearrangeOrder(
642642
createBy.data.order,
643643
createBy.data.onCallDutyPolicyId,
644-
true
644+
true,
645645
);
646646

647647
return {
@@ -652,11 +652,11 @@ export class Service extends DatabaseService<Model> {
652652

653653
@CaptureSpan()
654654
protected override async onBeforeDelete(
655-
deleteBy: DeleteBy<Model>
655+
deleteBy: DeleteBy<Model>,
656656
): Promise<OnDelete<Model>> {
657657
if (!deleteBy.query._id && !deleteBy.props.isRoot) {
658658
throw new BadDataException(
659-
"_id should be present when deleting status page resource. Please try the delete with objectId"
659+
"_id should be present when deleting status page resource. Please try the delete with objectId",
660660
);
661661
}
662662

@@ -677,7 +677,7 @@ export class Service extends DatabaseService<Model> {
677677

678678
if (!resource) {
679679
throw new BadDataException(
680-
"OnCallDutyPolicyEscalationRule with this id not found"
680+
"OnCallDutyPolicyEscalationRule with this id not found",
681681
);
682682
}
683683

@@ -730,7 +730,7 @@ export class Service extends DatabaseService<Model> {
730730
@CaptureSpan()
731731
protected override async onDeleteSuccess(
732732
onDelete: OnDelete<Model>,
733-
_itemIdsBeforeDelete: ObjectID[]
733+
_itemIdsBeforeDelete: ObjectID[],
734734
): Promise<OnDelete<Model>> {
735735
const deleteBy: DeleteBy<Model> = onDelete.deleteBy;
736736
const resource: Model | null = onDelete.carryForward;
@@ -741,7 +741,7 @@ export class Service extends DatabaseService<Model> {
741741
resource.order,
742742
resource.onCallDutyPolicyId,
743743

744-
false
744+
false,
745745
);
746746
}
747747
}
@@ -754,7 +754,7 @@ export class Service extends DatabaseService<Model> {
754754

755755
@CaptureSpan()
756756
protected override async onBeforeUpdate(
757-
updateBy: UpdateBy<Model>
757+
updateBy: UpdateBy<Model>,
758758
): Promise<OnUpdate<Model>> {
759759
if (updateBy.data.order && !updateBy.props.isRoot && updateBy.query._id) {
760760
const resource: Model | null = await this.findOneBy({
@@ -842,7 +842,7 @@ export class Service extends DatabaseService<Model> {
842842
private async rearrangeOrder(
843843
currentOrder: number,
844844
onCallDutyPolicyId: ObjectID,
845-
increaseOrder: boolean = true
845+
increaseOrder: boolean = true,
846846
): Promise<void> {
847847
// get status page resource with this order.
848848
const resources: Array<Model> = await this.findBy({

Common/Server/Services/OnCallDutyPolicyScheduleService.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export class Service extends DatabaseService<OnCallDutyPolicySchedule> {
144144
previousInformation.currentUserIdOnRoster?.toString() !==
145145
newInformation.currentUserIdOnRoster?.toString() ||
146146
previousInformation.rosterHandoffAt?.toString() !==
147-
newInformation.rosterHandoffAt?.toString()
147+
newInformation.rosterHandoffAt?.toString()
148148
) {
149149
if (
150150
previousInformation.currentUserIdOnRoster?.toString() !==
@@ -178,7 +178,11 @@ export class Service extends DatabaseService<OnCallDutyPolicySchedule> {
178178
}),
179179
rosterEndsAt:
180180
OneUptimeDate.getDateAsFormattedHTMLInMultipleTimezones({
181-
date: OneUptimeDate.isInTheFuture(previousInformation.rosterHandoffAt!) ? OneUptimeDate.getCurrentDate() : previousInformation.rosterHandoffAt!,
181+
date: OneUptimeDate.isInTheFuture(
182+
previousInformation.rosterHandoffAt!,
183+
)
184+
? OneUptimeDate.getCurrentDate()
185+
: previousInformation.rosterHandoffAt!,
182186
timezones: userTimezone ? [userTimezone] : [],
183187
}),
184188
onCallPolicyViewLink: (

Dashboard/src/Pages/UserSettings/NotificationSettings.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ const Settings: FunctionComponent<PageComponentProps> = (): ReactElement => {
183183
NotificationSettingEventType.SEND_WHEN_USER_IS_ADDED_TO_ON_CALL_POLICY,
184184
NotificationSettingEventType.SEND_WHEN_USER_IS_REMOVED_FROM_ON_CALL_POLICY,
185185
NotificationSettingEventType.SEND_WHEN_USER_IS_NO_LONGER_ACTIVE_ON_ON_CALL_ROSTER,
186-
187186
],
188187
title: "On-Call Notifications",
189188
description:

0 commit comments

Comments
 (0)