@opengis/admin 0.2.63 → 0.2.64
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,9 +1,10 @@
|
|
1
|
-
import { getTemplate, getMeta } from "@opengis/fastify-table/utils.js";
|
1
|
+
import { getTemplate, getMeta, handlebarsSync } from "@opengis/fastify-table/utils.js";
|
2
2
|
|
3
3
|
export default async function tableFilter(req) {
|
4
4
|
const time = Date.now();
|
5
5
|
const { pg, params = {}, session = {} } = req;
|
6
|
-
const {
|
6
|
+
const { user = {} } = session.passport || {};
|
7
|
+
const { uid } = user || {};
|
7
8
|
|
8
9
|
if (!params.name) {
|
9
10
|
return { message: 'not enouggh params: name', status: 400 };
|
@@ -43,9 +44,10 @@ export default async function tableFilter(req) {
|
|
43
44
|
}
|
44
45
|
if (!dataTypeID) return;
|
45
46
|
|
46
|
-
const
|
47
|
-
?
|
48
|
-
:
|
47
|
+
const q = pg.pgType?.[dataTypeID]?.includes('[]')
|
48
|
+
? `select unnest(${name})::text as id,count(*) from ${loadTable.table} where ${loadTable.query || '1=1'} group by unnest(${name})`
|
49
|
+
: `select ${name}::text as id,count(*) from ${loadTable.table} where ${loadTable.query || '1=1'} group by ${name}`;
|
50
|
+
const countArr = await pg.queryCache(handlebarsSync.compile(q)({ user, uid }), { table: loadTable.table, time: 5 })
|
49
51
|
|
50
52
|
/* if (!countArr.rows?.length) {
|
51
53
|
Object.assign(el, { options: cls.map((item) => ({ count: 0, ...item })) });
|