rez_core 4.0.58 → 4.0.59

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": "4.0.58",
3
+ "version": "4.0.59",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -28,45 +28,53 @@ export class FilterService {
28
28
  private readonly skipAppCodeFilterEntities = ['ORGP'];
29
29
  private readonly skipOrgFilterEntities = ['ORGP'];
30
30
 
31
+
31
32
  private async gettab_value_counts(
32
33
  tableName: string,
33
34
  column: string | undefined,
34
35
  whereClauses: { query: string; params: Record<string, any> }[],
35
36
  ) {
36
37
  if (!column) return [];
37
-
38
+
38
39
  let whereSQL = '';
39
40
  const values: any[] = [];
40
-
41
- // Convert whereClauses to SQL
41
+
42
42
  if (whereClauses.length > 0) {
43
43
  const clauseParts = whereClauses.map((clause) => {
44
- let parsedQuery = clause.query.replace(/\be\./g, ''); // removes e. prefix
44
+ let parsedQuery = clause.query.replace(/\be\./g, ''); // remove e.
45
+
45
46
  Object.entries(clause.params).forEach(([key, val]) => {
46
- parsedQuery = parsedQuery.replace(new RegExp(`:${key}`, 'g'), '?');
47
- values.push(val);
47
+ if (Array.isArray(val)) {
48
+ // if it's an array → expand placeholders (?, ?, ?)
49
+ const placeholders = val.map(() => '?').join(', ');
50
+ parsedQuery = parsedQuery.replace(new RegExp(`:${key}`, 'g'), `(${placeholders})`);
51
+ values.push(...val); // flatten values
52
+ } else {
53
+ parsedQuery = parsedQuery.replace(new RegExp(`:${key}`, 'g'), '?');
54
+ values.push(val);
55
+ }
48
56
  });
57
+
49
58
  return parsedQuery;
50
59
  });
51
-
60
+
52
61
  whereSQL = `WHERE ${clauseParts.join(' AND ')}`;
53
62
  }
54
-
55
- // Construct raw SQL
63
+
56
64
  const rawSQL = `
57
- SELECT ${column} AS tab_value, COUNT(*) AS tab_value_count
58
- FROM ${tableName}
59
- ${whereSQL}
60
- GROUP BY ${column}
61
- `;
62
-
65
+ SELECT ${column} AS tab_value, COUNT(*) AS tab_value_count
66
+ FROM ${tableName}
67
+ ${whereSQL}
68
+ GROUP BY ${column}
69
+ `;
70
+
63
71
  const rows = await this.dataSource.query(rawSQL, values);
64
-
72
+
65
73
  const total = rows.reduce(
66
74
  (sum, r) => sum + parseInt(r.tab_value_count, 10),
67
75
  0,
68
76
  );
69
-
77
+
70
78
  return [
71
79
  { tab_value: 'All', tab_value_count: total },
72
80
  ...rows.map((r) => ({
@@ -75,6 +83,7 @@ export class FilterService {
75
83
  })),
76
84
  ];
77
85
  }
86
+
78
87
 
79
88
  async applyFilterWrapper(dto: FilterRequestDto) {
80
89
  const {