rez_core 3.1.203 → 3.1.205

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "3.1.203",
3
+ "version": "3.1.205",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -55,6 +55,22 @@ export class ActionController {
55
55
  return result;
56
56
  }
57
57
 
58
+ @Post('/get_dependent_action')
59
+ @HttpCode(HttpStatus.OK)
60
+ async getDependentActions(
61
+ @Req() req: Request & { user: any },
62
+ @Body() body: { stage_id: number; action_id?: number },
63
+ ) {
64
+ const loggedInUser = req.user.userData;
65
+
66
+ const result = this.actionService.getDependentActions(
67
+ loggedInUser,
68
+ body.stage_id,
69
+ body.action_id,
70
+ );
71
+ return result;
72
+ }
73
+
58
74
  @Post('/getaction')
59
75
  @HttpCode(HttpStatus.OK)
60
76
  async getAction(
@@ -47,7 +47,7 @@ export class ActionDataEntity extends BaseEntity {
47
47
  @Column({ nullable: true, default: 0 })
48
48
  resubmit_count: number;
49
49
 
50
- @Column({ type: 'int', nullable: true })
50
+ @Column({ nullable: true })
51
51
  dependent_action_id: number;
52
52
 
53
53
  @Column({ type: 'varchar', nullable: true })
@@ -167,6 +167,52 @@ export class ActionRepository {
167
167
  return enrichedResult;
168
168
  }
169
169
 
170
+ async getDependentActions(
171
+ loggedInUser: UserData,
172
+ stage_id: number,
173
+ action_id?: number,
174
+ ) {
175
+ // Step 1: Get all action_ids for the provided stage_id
176
+ const stageActions = await this.dataSource.query(
177
+ `
178
+ SELECT action_id
179
+ FROM cr_wf_stage_action_mapping
180
+ WHERE stage_id = ?
181
+ `,
182
+ [stage_id],
183
+ );
184
+
185
+ if (!stageActions?.length) return [];
186
+
187
+ const actionIds = stageActions.map((sa) => sa.action_id);
188
+
189
+ // Step 2: Fetch action details except the provided action_id incase it is provided
190
+ const filteredActionIds = action_id
191
+ ? actionIds.filter((id) => id !== action_id)
192
+ : actionIds;
193
+
194
+ let actionResults;
195
+
196
+ if (filteredActionIds.length === 0) {
197
+ return [];
198
+ }
199
+
200
+ actionResults = await this.dataSource
201
+ .createQueryBuilder()
202
+ .select(['a.id AS action_id', 'a.name AS action_name'])
203
+ .from('cr_wf_action', 'a')
204
+ .andWhere('a.id IN(:...actionIds)', { actionIds: filteredActionIds })
205
+ .getRawMany();
206
+
207
+ // Step 3: Format result
208
+ const enrichedResult = actionResults.map((row) => ({
209
+ value: row.action_id,
210
+ label: row.action_name,
211
+ }));
212
+
213
+ return enrichedResult;
214
+ }
215
+
170
216
  async getAction(
171
217
  organization_id: number,
172
218
  stage_id: number,
@@ -246,6 +246,18 @@ export class ActionService extends EntityServiceImpl {
246
246
  return this.actionRepository.getActions(loggedInUser, stage_id);
247
247
  }
248
248
 
249
+ async getDependentActions(
250
+ loggedInUser: UserData,
251
+ stage_id: number,
252
+ action_id: number | undefined,
253
+ ) {
254
+ return this.actionRepository.getDependentActions(
255
+ loggedInUser,
256
+ stage_id,
257
+ action_id,
258
+ );
259
+ }
260
+
249
261
  async getAction(
250
262
  loggedInUser: UserData,
251
263
  stage_id: number,