rez_core 5.0.19 → 5.0.21

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": "5.0.19",
3
+ "version": "5.0.21",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -6,14 +6,20 @@ import {
6
6
  } from '@nestjs/common';
7
7
  import { StageGroup } from '../entity/stage-group.entity';
8
8
  import { InjectRepository } from '@nestjs/typeorm';
9
- import { DataSource, Repository } from 'typeorm';
9
+ import { DataSource, In, Repository } from 'typeorm';
10
10
  import { MediaDataService } from 'src/module/meta/service/media-data.service';
11
+ import { Stage } from '../entity/stage.entity';
12
+ import { TaskDataEntity } from '../entity/task-data.entity';
11
13
 
12
14
  @Injectable()
13
15
  export class StageGroupRepository {
14
16
  constructor(
15
17
  @InjectRepository(StageGroup)
16
18
  private readonly stageGroupRepository: Repository<StageGroup>,
19
+ @InjectRepository(Stage)
20
+ private readonly stageRepository: Repository<Stage>,
21
+ @InjectRepository(TaskDataEntity)
22
+ private readonly taskDataRepo: Repository<TaskDataEntity>,
17
23
  private readonly dataSource: DataSource,
18
24
  private readonly mediaDataService: MediaDataService,
19
25
  ) {}
@@ -83,22 +89,16 @@ export class StageGroupRepository {
83
89
  // -------------------------------------------------------------
84
90
 
85
91
  const stageGroupIds = stageGroups.map((sg) => Number(sg.id));
86
- const stageGroupPlaceholders = stageGroupIds
87
- .map((_, idx) => `$${idx + 1}`)
88
- .join(", ");
89
-
90
- const params_stage = [...stageGroupIds, Number(loggedInUser.organization_id)];
91
92
 
92
- const stagesRaw = await this.dataSource.query(
93
- `
94
- SELECT frm_wf_stage.*
95
- FROM frm_wf_stage
96
- WHERE frm_wf_stage.stage_group_id IN (${stageGroupPlaceholders})
97
- AND frm_wf_stage.organization_id = $${stageGroupIds.length + 1}
98
- ORDER BY frm_wf_stage.sequence ASC
99
- `,
100
- params_stage,
101
- );
93
+ const stagesRaw: any[] = await this.stageRepository.find({
94
+ where: {
95
+ stage_group_id: In(stageGroupIds),
96
+ organization_id: loggedInUser.organization_id
97
+ },
98
+ order: {
99
+ sequence: 'ASC',
100
+ }
101
+ })
102
102
 
103
103
  const stageIds = stagesRaw.map((s) => Number(s.id));
104
104
 
@@ -113,15 +113,15 @@ export class StageGroupRepository {
113
113
  .map((_, idx) => `$${idx + 1}`)
114
114
  .join(", ");
115
115
 
116
- const params_task = [...stageIds, Number(lead_id)];
116
+ const params_task = [...stageIds];
117
117
 
118
118
  const taskCounts = await this.dataSource.query(
119
119
  `
120
120
  SELECT stage_id, COUNT(*) AS task_count
121
121
  FROM frm_wf_task_data
122
122
  WHERE stage_id IN (${stagePlaceholders})
123
- AND is_system = 0
124
- AND mapped_entity_id = $${stageIds.length + 1}
123
+ AND is_system = FALSE
124
+ AND mapped_entity_id = lead_id
125
125
  GROUP BY stage_id
126
126
  `,
127
127
  params_task,
@@ -135,7 +135,7 @@ export class StageGroupRepository {
135
135
  SELECT stage_id, COUNT(*) AS meeting_count
136
136
  FROM crm_lead_meeting
137
137
  WHERE stage_id IN (${stagePlaceholders})
138
- AND mapped_entity_id = $${stageIds.length + 1}
138
+ AND mapped_entity_id = lead_id
139
139
  GROUP BY stage_id
140
140
  `,
141
141
  params_task,
@@ -149,7 +149,7 @@ export class StageGroupRepository {
149
149
  SELECT stage_id, COUNT(*) AS send_comm_count
150
150
  FROM crm_lead_communication
151
151
  WHERE stage_id IN (${stagePlaceholders})
152
- AND mapped_entity_id = $${stageIds.length + 1}
152
+ AND mapped_entity_id = lead_id
153
153
  AND type IN ('SEND','LOG')
154
154
  GROUP BY stage_id
155
155
  `,