@oneuptime/common 7.0.4003 → 7.0.4007

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/Models/DatabaseModels/OnCallDutyPolicySchedule.ts +68 -1
  2. package/Models/DatabaseModels/OnCallDutyPolicyScheduleLayer.ts +0 -79
  3. package/Server/API/OnCallDutyPolicyAPI.ts +87 -0
  4. package/Server/Infrastructure/Postgres/SchemaMigrations/1743692467814-MigrationName.ts +35 -0
  5. package/Server/Infrastructure/Postgres/SchemaMigrations/1743714801105-MigrationName.ts +23 -0
  6. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
  7. package/Server/Services/OnCallDutyPolicyScheduleLayerService.ts +61 -1
  8. package/Server/Services/OnCallDutyPolicyScheduleLayerUserService.ts +63 -0
  9. package/Server/Services/OnCallDutyPolicyScheduleService.ts +216 -15
  10. package/Server/Services/OnCallDutyPolicyService.ts +129 -0
  11. package/Server/Services/TeamService.ts +36 -0
  12. package/Types/Date.ts +23 -7
  13. package/Types/OnCallDutyPolicy/Layer.ts +104 -20
  14. package/UI/Components/Alerts/Alert.tsx +6 -5
  15. package/UI/Components/HeaderAlert/HeaderAlert.tsx +2 -2
  16. package/build/dist/Models/DatabaseModels/OnCallDutyPolicySchedule.js +70 -1
  17. package/build/dist/Models/DatabaseModels/OnCallDutyPolicySchedule.js.map +1 -1
  18. package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleLayer.js +0 -82
  19. package/build/dist/Models/DatabaseModels/OnCallDutyPolicyScheduleLayer.js.map +1 -1
  20. package/build/dist/Server/API/OnCallDutyPolicyAPI.js +44 -0
  21. package/build/dist/Server/API/OnCallDutyPolicyAPI.js.map +1 -0
  22. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1743692467814-MigrationName.js +18 -0
  23. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1743692467814-MigrationName.js.map +1 -0
  24. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1743714801105-MigrationName.js +14 -0
  25. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1743714801105-MigrationName.js.map +1 -0
  26. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
  27. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  28. package/build/dist/Server/Services/OnCallDutyPolicyScheduleLayerService.js +39 -0
  29. package/build/dist/Server/Services/OnCallDutyPolicyScheduleLayerService.js.map +1 -1
  30. package/build/dist/Server/Services/OnCallDutyPolicyScheduleLayerUserService.js +42 -0
  31. package/build/dist/Server/Services/OnCallDutyPolicyScheduleLayerUserService.js.map +1 -1
  32. package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js +129 -6
  33. package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js.map +1 -1
  34. package/build/dist/Server/Services/OnCallDutyPolicyService.js +101 -0
  35. package/build/dist/Server/Services/OnCallDutyPolicyService.js.map +1 -1
  36. package/build/dist/Server/Services/TeamService.js +27 -0
  37. package/build/dist/Server/Services/TeamService.js.map +1 -1
  38. package/build/dist/Types/Date.js +19 -7
  39. package/build/dist/Types/Date.js.map +1 -1
  40. package/build/dist/Types/OnCallDutyPolicy/Layer.js +66 -11
  41. package/build/dist/Types/OnCallDutyPolicy/Layer.js.map +1 -1
  42. package/build/dist/UI/Components/Alerts/Alert.js +4 -4
  43. package/build/dist/UI/Components/Alerts/Alert.js.map +1 -1
  44. package/build/dist/UI/Components/HeaderAlert/HeaderAlert.js +2 -2
  45. package/build/dist/UI/Components/HeaderAlert/HeaderAlert.js.map +1 -1
  46. package/package.json +2 -2
@@ -517,6 +517,28 @@ export default class OnCallDutyPolicySchedule extends BaseModel {
517
517
  })
518
518
  public nextUserIdOnRoster?: ObjectID = undefined;
519
519
 
520
+ @ColumnAccessControl({
521
+ create: [],
522
+ read: [
523
+ Permission.ProjectOwner,
524
+ Permission.ProjectAdmin,
525
+ Permission.ProjectMember,
526
+ Permission.ReadProjectOnCallDutyPolicySchedule,
527
+ ],
528
+ update: [],
529
+ })
530
+ @TableColumn({
531
+ type: TableColumnType.Date,
532
+ title: "Roster Handoff At",
533
+ description:
534
+ "When does the roster handoff occur for this schedule for the current user?",
535
+ })
536
+ @Column({
537
+ type: ColumnType.Date,
538
+ nullable: true,
539
+ })
540
+ public rosterHandoffAt?: Date = undefined;
541
+
520
542
  @ColumnAccessControl({
521
543
  create: [],
522
544
  read: [
@@ -530,11 +552,56 @@ export default class OnCallDutyPolicySchedule extends BaseModel {
530
552
  @TableColumn({
531
553
  type: TableColumnType.Date,
532
554
  title: "Roster Next Handoff At",
533
- description: "When is the next roster handoff for this schedule?",
555
+ description:
556
+ "When does the next roster handoff occur for this schedule for the next user?",
534
557
  })
535
558
  @Column({
536
559
  type: ColumnType.Date,
537
560
  nullable: true,
538
561
  })
539
562
  public rosterNextHandoffAt?: Date = undefined;
563
+
564
+ @ColumnAccessControl({
565
+ create: [],
566
+ read: [
567
+ Permission.ProjectOwner,
568
+ Permission.ProjectAdmin,
569
+ Permission.ProjectMember,
570
+ Permission.ReadProjectOnCallDutyPolicySchedule,
571
+ ],
572
+ update: [],
573
+ })
574
+ @TableColumn({
575
+ type: TableColumnType.Date,
576
+ title: "Roster Next Event Start At",
577
+ description:
578
+ "When does the next event start for this schedule for the next user?",
579
+ })
580
+ @Column({
581
+ type: ColumnType.Date,
582
+ nullable: true,
583
+ })
584
+ public rosterNextStartAt?: Date = undefined;
585
+
586
+ @ColumnAccessControl({
587
+ create: [],
588
+ read: [
589
+ Permission.ProjectOwner,
590
+ Permission.ProjectAdmin,
591
+ Permission.ProjectMember,
592
+ Permission.ReadProjectOnCallDutyPolicySchedule,
593
+ ],
594
+ update: [],
595
+ })
596
+ @TableColumn({
597
+ type: TableColumnType.Date,
598
+ title: "Roster Event Start At",
599
+ description:
600
+ "When does the current event start for this schedule for the current user?",
601
+ })
602
+ @Column({
603
+ type: ColumnType.Date,
604
+ nullable: true,
605
+ })
606
+ public rosterStartAt?: Date = undefined;
540
607
  }
@@ -552,83 +552,4 @@ export default class OnCallDutyPolicyScheduleLayer extends BaseModel {
552
552
  transformer: RestrictionTimes.getDatabaseTransformer(),
553
553
  })
554
554
  public restrictionTimes?: RestrictionTimes = undefined;
555
-
556
- @ColumnAccessControl({
557
- create: [
558
- Permission.ProjectOwner,
559
- Permission.ProjectAdmin,
560
- Permission.ProjectMember,
561
- Permission.CreateProjectOnCallDutyPolicySchedule,
562
- ],
563
- read: [
564
- Permission.ProjectOwner,
565
- Permission.ProjectAdmin,
566
- Permission.ProjectMember,
567
- Permission.ReadProjectOnCallDutyPolicySchedule,
568
- ],
569
- update: [],
570
- })
571
- @TableColumn({
572
- manyToOneRelationColumn: "nextUserIdOnLayer",
573
- type: TableColumnType.Entity,
574
- modelType: User,
575
- title: "Next User On Layer",
576
- description: "Relation to User who is next on layer",
577
- })
578
- @ManyToOne(
579
- () => {
580
- return User;
581
- },
582
- {
583
- eager: false,
584
- nullable: true,
585
- onDelete: "SET NULL",
586
- orphanedRowAction: "nullify",
587
- },
588
- )
589
- @JoinColumn({ name: "nextUserIdOnLayer" })
590
- public nextUserOnLayer?: User = undefined;
591
-
592
- @ColumnAccessControl({
593
- create: [],
594
- read: [
595
- Permission.ProjectOwner,
596
- Permission.ProjectAdmin,
597
- Permission.ProjectMember,
598
- Permission.ReadProjectOnCallDutyPolicySchedule,
599
- ],
600
- update: [],
601
- })
602
- @TableColumn({
603
- type: TableColumnType.ObjectID,
604
- title: "Next User ID On Layer",
605
- description: "Next ID who is currently on layer",
606
- })
607
- @Column({
608
- type: ColumnType.ObjectID,
609
- nullable: true,
610
- transformer: ObjectID.getDatabaseTransformer(),
611
- })
612
- public nextUserIdOnLayer?: ObjectID = undefined;
613
-
614
- @ColumnAccessControl({
615
- create: [],
616
- read: [
617
- Permission.ProjectOwner,
618
- Permission.ProjectAdmin,
619
- Permission.ProjectMember,
620
- Permission.ReadProjectOnCallDutyPolicySchedule,
621
- ],
622
- update: [],
623
- })
624
- @TableColumn({
625
- type: TableColumnType.Date,
626
- title: "Layer Next Handoff At",
627
- description: "When is the next layer handoff for this schedule?",
628
- })
629
- @Column({
630
- type: ColumnType.Date,
631
- nullable: true,
632
- })
633
- public layerNextHandoffAt?: Date = undefined;
634
555
  }
@@ -0,0 +1,87 @@
1
+ import UserMiddleware from "../Middleware/UserAuthorization";
2
+ import OnCallDutyPolicyService, {
3
+ Service as OnCallDutyPolicyServiceType,
4
+ } from "../Services/OnCallDutyPolicyService";
5
+ import {
6
+ ExpressRequest,
7
+ ExpressResponse,
8
+ NextFunction,
9
+ } from "../Utils/Express";
10
+ import Response from "../Utils/Response";
11
+ import BaseAPI from "./BaseAPI";
12
+ import CommonAPI from "./CommonAPI";
13
+ import DatabaseCommonInteractionProps from "Common/Types/BaseDatabase/DatabaseCommonInteractionProps";
14
+ import BadDataException from "Common/Types/Exception/BadDataException";
15
+ import ObjectID from "Common/Types/ObjectID";
16
+ import OnCallDutyPolicy from "Common/Models/DatabaseModels/OnCallDutyPolicy";
17
+ import OnCallDutyPolicyEscalationRuleUser from "../../Models/DatabaseModels/OnCallDutyPolicyEscalationRuleUser";
18
+ import OnCallDutyPolicyEscalationRuleTeam from "../../Models/DatabaseModels/OnCallDutyPolicyEscalationRuleTeam";
19
+ import OnCallDutyPolicyEscalationRuleSchedule from "../../Models/DatabaseModels/OnCallDutyPolicyEscalationRuleSchedule";
20
+ import BaseModel from "Common/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel";
21
+
22
+ export default class OnCallDutyPolicyAPI extends BaseAPI<
23
+ OnCallDutyPolicy,
24
+ OnCallDutyPolicyServiceType
25
+ > {
26
+ public constructor() {
27
+ super(OnCallDutyPolicy, OnCallDutyPolicyService);
28
+
29
+ // CNAME verification api. THis API will be used from the dashboard to validate the CNAME MANUALLY.
30
+ this.router.get(
31
+ `${new this.entityType().getCrudApiPath()?.toString()}/current-on-duty-escalation-policies`,
32
+ UserMiddleware.getUserMiddleware,
33
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
34
+ try {
35
+ const databaseProps: DatabaseCommonInteractionProps =
36
+ await CommonAPI.getDatabaseCommonInteractionProps(req);
37
+
38
+ const projectId: ObjectID = databaseProps.tenantId as ObjectID;
39
+
40
+ const userId: ObjectID = databaseProps.userId as ObjectID;
41
+
42
+ if (!projectId) {
43
+ return Response.sendErrorResponse(
44
+ req,
45
+ res,
46
+ new BadDataException("Invalid projectId."),
47
+ );
48
+ }
49
+
50
+ if (!userId) {
51
+ return Response.sendErrorResponse(
52
+ req,
53
+ res,
54
+ new BadDataException("Invalid userId."),
55
+ );
56
+ }
57
+
58
+ const result: {
59
+ escalationRulesByUser: Array<OnCallDutyPolicyEscalationRuleUser>;
60
+ escalationRulesByTeam: Array<OnCallDutyPolicyEscalationRuleTeam>;
61
+ escalationRulesBySchedule: Array<OnCallDutyPolicyEscalationRuleSchedule>;
62
+ } = await this.service.getOnCallPoliciesWhereUserIsOnCallDuty({
63
+ projectId: projectId,
64
+ userId: userId,
65
+ });
66
+
67
+ return Response.sendJsonObjectResponse(req, res, {
68
+ escalationRulesByUser: BaseModel.toJSONArray(
69
+ result.escalationRulesByUser,
70
+ OnCallDutyPolicyEscalationRuleUser,
71
+ ),
72
+ escalationRulesByTeam: BaseModel.toJSONArray(
73
+ result.escalationRulesByTeam,
74
+ OnCallDutyPolicyEscalationRuleTeam,
75
+ ),
76
+ escalationRulesBySchedule: BaseModel.toJSONArray(
77
+ result.escalationRulesBySchedule,
78
+ OnCallDutyPolicyEscalationRuleSchedule,
79
+ ),
80
+ });
81
+ } catch (e) {
82
+ next(e);
83
+ }
84
+ },
85
+ );
86
+ }
87
+ }
@@ -0,0 +1,35 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1743692467814 implements MigrationInterface {
4
+ public name = "MigrationName1743692467814";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" DROP CONSTRAINT "FK_815023b155d367f28cc6855b843"`,
9
+ );
10
+ await queryRunner.query(
11
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" DROP COLUMN "nextUserIdOnLayer"`,
12
+ );
13
+ await queryRunner.query(
14
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" DROP COLUMN "layerNextHandoffAt"`,
15
+ );
16
+ await queryRunner.query(
17
+ `ALTER TABLE "OnCallDutyPolicySchedule" ADD "rosterHandoffAt" TIMESTAMP WITH TIME ZONE`,
18
+ );
19
+ }
20
+
21
+ public async down(queryRunner: QueryRunner): Promise<void> {
22
+ await queryRunner.query(
23
+ `ALTER TABLE "OnCallDutyPolicySchedule" DROP COLUMN "rosterHandoffAt"`,
24
+ );
25
+ await queryRunner.query(
26
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ADD "layerNextHandoffAt" TIMESTAMP WITH TIME ZONE`,
27
+ );
28
+ await queryRunner.query(
29
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ADD "nextUserIdOnLayer" uuid`,
30
+ );
31
+ await queryRunner.query(
32
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ADD CONSTRAINT "FK_815023b155d367f28cc6855b843" FOREIGN KEY ("nextUserIdOnLayer") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
33
+ );
34
+ }
35
+ }
@@ -0,0 +1,23 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1743714801105 implements MigrationInterface {
4
+ public name = "MigrationName1743714801105";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `ALTER TABLE "OnCallDutyPolicySchedule" ADD "rosterNextStartAt" TIMESTAMP WITH TIME ZONE`,
9
+ );
10
+ await queryRunner.query(
11
+ `ALTER TABLE "OnCallDutyPolicySchedule" ADD "rosterStartAt" TIMESTAMP WITH TIME ZONE`,
12
+ );
13
+ }
14
+
15
+ public async down(queryRunner: QueryRunner): Promise<void> {
16
+ await queryRunner.query(
17
+ `ALTER TABLE "OnCallDutyPolicySchedule" DROP COLUMN "rosterStartAt"`,
18
+ );
19
+ await queryRunner.query(
20
+ `ALTER TABLE "OnCallDutyPolicySchedule" DROP COLUMN "rosterNextStartAt"`,
21
+ );
22
+ }
23
+ }
@@ -127,6 +127,8 @@ import { MigrationName1743518485566 } from "./1743518485566-MigrationName";
127
127
  import { MigrationName1743521461137 } from "./1743521461137-MigrationName";
128
128
  import { MigrationName1743530326936 } from "./1743530326936-MigrationName";
129
129
  import { MigrationName1743538648415 } from "./1743538648415-MigrationName";
130
+ import { MigrationName1743692467814 } from "./1743692467814-MigrationName";
131
+ import { MigrationName1743714801105 } from "./1743714801105-MigrationName";
130
132
 
131
133
  export default [
132
134
  InitialMigration,
@@ -258,4 +260,6 @@ export default [
258
260
  MigrationName1743521461137,
259
261
  MigrationName1743530326936,
260
262
  MigrationName1743538648415,
263
+ MigrationName1743692467814,
264
+ MigrationName1743714801105,
261
265
  ];
@@ -1,6 +1,6 @@
1
1
  import CreateBy from "../Types/Database/CreateBy";
2
2
  import DeleteBy from "../Types/Database/DeleteBy";
3
- import { OnCreate, OnDelete } from "../Types/Database/Hooks";
3
+ import { OnCreate, OnDelete, OnUpdate } from "../Types/Database/Hooks";
4
4
  import QueryHelper from "../Types/Database/QueryHelper";
5
5
  import DatabaseService from "./DatabaseService";
6
6
  import SortOrder from "../../Types/BaseDatabase/SortOrder";
@@ -10,6 +10,7 @@ import ObjectID from "../../Types/ObjectID";
10
10
  import PositiveNumber from "../../Types/PositiveNumber";
11
11
  import Model from "Common/Models/DatabaseModels/OnCallDutyPolicyScheduleLayer";
12
12
  import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
13
+ import OnCallDutyPolicyScheduleService from "./OnCallDutyPolicyScheduleService";
13
14
 
14
15
  export class Service extends DatabaseService<Model> {
15
16
  public constructor() {
@@ -51,6 +52,61 @@ export class Service extends DatabaseService<Model> {
51
52
  };
52
53
  }
53
54
 
55
+ protected override async onCreateSuccess(
56
+ _onCreate: OnCreate<Model>,
57
+ createdItem: Model,
58
+ ): Promise<Model> {
59
+ const resource: Model | null = await this.findOneById({
60
+ id: createdItem.id!,
61
+ select: {
62
+ onCallDutyPolicyScheduleId: true,
63
+ },
64
+ props: {
65
+ isRoot: true,
66
+ },
67
+ });
68
+
69
+ if (!resource || !resource.onCallDutyPolicyScheduleId) {
70
+ return createdItem;
71
+ }
72
+
73
+ await OnCallDutyPolicyScheduleService.refreshCurrentUserIdAndHandoffTimeInSchedule(
74
+ resource.onCallDutyPolicyScheduleId,
75
+ );
76
+
77
+ return createdItem;
78
+ }
79
+
80
+ protected override async onUpdateSuccess(
81
+ _onUpdate: OnUpdate<Model>,
82
+ updatedItemIds: Array<ObjectID>,
83
+ ): Promise<OnUpdate<Model>> {
84
+ for (const item of updatedItemIds) {
85
+ const resource: Model | null = await this.findOneById({
86
+ id: item,
87
+ select: {
88
+ onCallDutyPolicyScheduleId: true,
89
+ },
90
+ props: {
91
+ isRoot: true,
92
+ },
93
+ });
94
+
95
+ if (!resource || !resource.onCallDutyPolicyScheduleId) {
96
+ continue;
97
+ }
98
+
99
+ await OnCallDutyPolicyScheduleService.refreshCurrentUserIdAndHandoffTimeInSchedule(
100
+ resource.onCallDutyPolicyScheduleId,
101
+ );
102
+ }
103
+
104
+ return {
105
+ updateBy: _onUpdate.updateBy,
106
+ carryForward: null,
107
+ };
108
+ }
109
+
54
110
  @CaptureSpan()
55
111
  protected override async onDeleteSuccess(
56
112
  onDelete: OnDelete<Model>,
@@ -66,6 +122,10 @@ export class Service extends DatabaseService<Model> {
66
122
  resource.onCallDutyPolicyScheduleId,
67
123
  false,
68
124
  );
125
+
126
+ await OnCallDutyPolicyScheduleService.refreshCurrentUserIdAndHandoffTimeInSchedule(
127
+ resource.onCallDutyPolicyScheduleId,
128
+ );
69
129
  }
70
130
  }
71
131
 
@@ -11,6 +11,7 @@ import ObjectID from "../../Types/ObjectID";
11
11
  import PositiveNumber from "../../Types/PositiveNumber";
12
12
  import Model from "Common/Models/DatabaseModels/OnCallDutyPolicyScheduleLayerUser";
13
13
  import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
14
+ import OnCallDutyPolicyScheduleService from "./OnCallDutyPolicyScheduleService";
14
15
 
15
16
  export class Service extends DatabaseService<Model> {
16
17
  public constructor() {
@@ -79,6 +80,12 @@ export class Service extends DatabaseService<Model> {
79
80
  resource.onCallDutyPolicyScheduleLayerId,
80
81
  false,
81
82
  );
83
+
84
+ if (resource.onCallDutyPolicyScheduleId) {
85
+ await OnCallDutyPolicyScheduleService.refreshCurrentUserIdAndHandoffTimeInSchedule(
86
+ resource.onCallDutyPolicyScheduleId,
87
+ );
88
+ }
82
89
  }
83
90
  }
84
91
 
@@ -109,6 +116,7 @@ export class Service extends DatabaseService<Model> {
109
116
  select: {
110
117
  order: true,
111
118
  onCallDutyPolicyScheduleLayerId: true,
119
+ onCallDutyPolicyScheduleId: true,
112
120
  },
113
121
  });
114
122
  }
@@ -119,6 +127,61 @@ export class Service extends DatabaseService<Model> {
119
127
  };
120
128
  }
121
129
 
130
+ protected override async onCreateSuccess(
131
+ _onCreate: OnCreate<Model>,
132
+ createdItem: Model,
133
+ ): Promise<Model> {
134
+ const resource: Model | null = await this.findOneById({
135
+ id: createdItem.id!,
136
+ select: {
137
+ onCallDutyPolicyScheduleId: true,
138
+ },
139
+ props: {
140
+ isRoot: true,
141
+ },
142
+ });
143
+
144
+ if (!resource || !resource.onCallDutyPolicyScheduleId) {
145
+ return createdItem;
146
+ }
147
+
148
+ await OnCallDutyPolicyScheduleService.refreshCurrentUserIdAndHandoffTimeInSchedule(
149
+ resource.onCallDutyPolicyScheduleId,
150
+ );
151
+
152
+ return createdItem;
153
+ }
154
+
155
+ protected override async onUpdateSuccess(
156
+ _onUpdate: OnUpdate<Model>,
157
+ updatedItemIds: Array<ObjectID>,
158
+ ): Promise<OnUpdate<Model>> {
159
+ for (const item of updatedItemIds) {
160
+ const resource: Model | null = await this.findOneById({
161
+ id: item,
162
+ select: {
163
+ onCallDutyPolicyScheduleId: true,
164
+ },
165
+ props: {
166
+ isRoot: true,
167
+ },
168
+ });
169
+
170
+ if (!resource || !resource.onCallDutyPolicyScheduleId) {
171
+ continue;
172
+ }
173
+
174
+ await OnCallDutyPolicyScheduleService.refreshCurrentUserIdAndHandoffTimeInSchedule(
175
+ resource.onCallDutyPolicyScheduleId,
176
+ );
177
+ }
178
+
179
+ return {
180
+ updateBy: _onUpdate.updateBy,
181
+ carryForward: null,
182
+ };
183
+ }
184
+
122
185
  @CaptureSpan()
123
186
  protected override async onBeforeUpdate(
124
187
  updateBy: UpdateBy<Model>,