rez_core 2.2.69 → 2.2.70

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": "2.2.69",
3
+ "version": "2.2.70",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -43,6 +43,7 @@ export class StageGroupRepository {
43
43
  async getAllStageGroupAndStageHierarchy(
44
44
  workflow_id: number,
45
45
  organization_id: number,
46
+ lead_id: number,
46
47
  ) {
47
48
  if (!workflow_id) {
48
49
  throw new BadRequestException('workflow_id is required');
@@ -81,10 +82,10 @@ export class StageGroupRepository {
81
82
  `
82
83
  SELECT stage_id, COUNT(*) AS task_count
83
84
  FROM cr_wf_task_data
84
- WHERE stage_id IN (${stageIds.map(() => '?').join(',')}) AND is_system=0
85
+ WHERE stage_id IN (${stageIds.map(() => '?').join(',')}) AND is_system=0 AND mapped_entity_id = ?
85
86
  GROUP BY stage_id
86
87
  `,
87
- [...stageIds],
88
+ [...stageIds, lead_id],
88
89
  );
89
90
 
90
91
  // Meeting counts
@@ -92,10 +93,10 @@ export class StageGroupRepository {
92
93
  `
93
94
  SELECT stage_id, COUNT(*) AS meeting_count
94
95
  FROM cr_lead_meeting
95
- WHERE stage_id IN (${stageIds.map(() => '?').join(',')})
96
+ WHERE stage_id IN (${stageIds.map(() => '?').join(',')}) AND lead_id = ?
96
97
  GROUP BY stage_id
97
98
  `,
98
- [...stageIds],
99
+ [...stageIds, lead_id],
99
100
  );
100
101
 
101
102
  // Send communication counts
@@ -103,38 +104,36 @@ export class StageGroupRepository {
103
104
  `
104
105
  SELECT stage_id, COUNT(*) AS send_comm_count
105
106
  FROM cr_lead_communication
106
- WHERE stage_id IN (${stageIds.map(() => '?').join(',')})
107
+ WHERE stage_id IN (${stageIds.map(() => '?').join(',')}) AND lead_id = ?
107
108
  AND type IN ('SEND', 'LOG')
108
109
  GROUP BY stage_id
109
110
  `,
110
- [...stageIds],
111
- );
112
-
113
- const logIntCounts = await this.dataSource.query(
114
- `
115
- SELECT stage_id, COUNT(*) AS send_comm_count
116
- FROM cr_lead_communication
117
- WHERE stage_id IN (${stageIds.map(() => '?').join(',')}) AND type = 'LOG'
118
- GROUP BY stage_id
119
- `,
120
- [...stageIds],
111
+ [...stageIds, lead_id],
121
112
  );
122
113
 
114
+ // Convert to maps for quick lookup
123
115
  // Convert to maps for quick lookup
124
116
  const taskCountMap = new Map(
125
- taskCounts.map((row) => [row.stage_id, row.task_count]),
117
+ taskCounts.map((row) => [Number(row.stage_id), Number(row.task_count)]),
126
118
  );
127
119
  const meetingCountMap = new Map(
128
- meetingCounts.map((row) => [row.stage_id, row.meeting_count]),
120
+ meetingCounts.map((row) => [
121
+ Number(row.stage_id),
122
+ Number(row.meeting_count),
123
+ ]),
129
124
  );
130
125
  const sendCommCountMap = new Map(
131
- sendCommCounts.map((row) => [row.stage_id, row.send_comm_count]),
126
+ sendCommCounts.map((row) => [
127
+ Number(row.stage_id),
128
+ Number(row.send_comm_count),
129
+ ]),
132
130
  );
133
131
 
134
132
  // Step 4: Add counts to each stage
135
133
  const stageMap = new Map<number, any[]>();
136
134
  for (const stage of stages) {
137
- const stageId = Number(stage.id);
135
+ const stageId = Number(stage.id); // ensure number
136
+
138
137
  stage.task_count = taskCountMap.get(stageId) || 0;
139
138
  stage.meeting_count = meetingCountMap.get(stageId) || 0;
140
139
  stage.send_comm_count = sendCommCountMap.get(stageId) || 0;
@@ -75,6 +75,7 @@ export class StageGroupService extends EntityServiceImpl {
75
75
  (await this.stageGroupRepository.getAllStageGroupAndStageHierarchy(
76
76
  workflowLevelMapping.workflow_id,
77
77
  loggedInUser.organization_id,
78
+ lead_id,
78
79
  )) as Array<{
79
80
  stages: any[];
80
81
  stage_group_status?: string; // Extend type here to satisfy TS