rez_core 4.0.58 → 4.0.60
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
|
@@ -28,45 +28,65 @@ 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, ''); //
|
|
44
|
+
let parsedQuery = clause.query.replace(/\be\./g, ''); // remove e. prefix
|
|
45
|
+
|
|
45
46
|
Object.entries(clause.params).forEach(([key, val]) => {
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
if (Array.isArray(val)) {
|
|
48
|
+
// if the query uses '=' but the param is array → convert to IN
|
|
49
|
+
if (parsedQuery.includes(`= :${key}`)) {
|
|
50
|
+
parsedQuery = parsedQuery.replace(`= :${key}`, `IN (:${key})`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// generate (?, ?, ?) placeholders
|
|
54
|
+
const placeholders = val.map(() => '?').join(', ');
|
|
55
|
+
parsedQuery = parsedQuery.replace(
|
|
56
|
+
new RegExp(`:\\b${key}\\b`, 'g'),
|
|
57
|
+
placeholders,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
values.push(...val);
|
|
61
|
+
} else {
|
|
62
|
+
parsedQuery = parsedQuery.replace(
|
|
63
|
+
new RegExp(`:\\b${key}\\b`, 'g'),
|
|
64
|
+
'?',
|
|
65
|
+
);
|
|
66
|
+
values.push(val);
|
|
67
|
+
}
|
|
48
68
|
});
|
|
69
|
+
|
|
49
70
|
return parsedQuery;
|
|
50
71
|
});
|
|
51
|
-
|
|
72
|
+
|
|
52
73
|
whereSQL = `WHERE ${clauseParts.join(' AND ')}`;
|
|
53
74
|
}
|
|
54
|
-
|
|
55
|
-
// Construct raw SQL
|
|
75
|
+
|
|
56
76
|
const rawSQL = `
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
`;
|
|
62
|
-
|
|
77
|
+
SELECT ${column} AS tab_value, COUNT(*) AS tab_value_count
|
|
78
|
+
FROM ${tableName}
|
|
79
|
+
${whereSQL}
|
|
80
|
+
GROUP BY ${column}
|
|
81
|
+
`;
|
|
82
|
+
|
|
63
83
|
const rows = await this.dataSource.query(rawSQL, values);
|
|
64
|
-
|
|
84
|
+
|
|
65
85
|
const total = rows.reduce(
|
|
66
86
|
(sum, r) => sum + parseInt(r.tab_value_count, 10),
|
|
67
87
|
0,
|
|
68
88
|
);
|
|
69
|
-
|
|
89
|
+
|
|
70
90
|
return [
|
|
71
91
|
{ tab_value: 'All', tab_value_count: total },
|
|
72
92
|
...rows.map((r) => ({
|
|
@@ -75,6 +95,8 @@ export class FilterService {
|
|
|
75
95
|
})),
|
|
76
96
|
];
|
|
77
97
|
}
|
|
98
|
+
|
|
99
|
+
|
|
78
100
|
|
|
79
101
|
async applyFilterWrapper(dto: FilterRequestDto) {
|
|
80
102
|
const {
|