@opengis/gis 0.1.77 → 0.1.78
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/dist/index.js +577 -577
- package/dist/index.umd.cjs +4 -4
- package/module/test/cls/doc_status.json +31 -31
- package/module/test/select/core.user_uid.sql +1 -1
- package/package.json +61 -58
- package/server/plugins/mapnik/funcs/map.proto +241 -241
- package/server/routes/gis/registers/funcs/classifiers.js +47 -1
- package/server/routes/gis/registers/funcs/handleRegistryRequest.js +9 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getSelectVal } from '@opengis/fastify-table/utils.js';
|
|
1
|
+
import { getSelectVal, getSelect } from '@opengis/fastify-table/utils.js';
|
|
2
2
|
|
|
3
3
|
export async function attachClassifiers(rowOrRows, classifiers = []) {
|
|
4
4
|
const rows = Array.isArray(rowOrRows) ? rowOrRows : [rowOrRows];
|
|
@@ -35,3 +35,49 @@ export async function attachClassifiers(rowOrRows, classifiers = []) {
|
|
|
35
35
|
|
|
36
36
|
return rowOrRows;
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
export async function populateFilterOptions({ pg, table, filters, columns, whereConditions }) {
|
|
40
|
+
if (!filters?.length || !table || !columns?.length) return;
|
|
41
|
+
|
|
42
|
+
const optimizedSQL = `select * from ${table} where ${whereConditions || '1=1'}`;
|
|
43
|
+
|
|
44
|
+
await Promise.all(
|
|
45
|
+
filters
|
|
46
|
+
.filter(
|
|
47
|
+
(el) =>
|
|
48
|
+
el.id &&
|
|
49
|
+
el.type !== "Autocomplete" &&
|
|
50
|
+
!el.sql &&
|
|
51
|
+
!el.options?.find?.((item) => item.sql)
|
|
52
|
+
)
|
|
53
|
+
.map(async (el) => {
|
|
54
|
+
const cls = el.data ? await getSelect(el.data, pg) : null;
|
|
55
|
+
|
|
56
|
+
if (!cls && !el.type?.includes?.("Check")) return;
|
|
57
|
+
const { dataTypeID } = (columns || []).find((item) => item.name === el.id) || {};
|
|
58
|
+
|
|
59
|
+
const q = pg.pgType[dataTypeID || '']?.includes("[]")
|
|
60
|
+
? `select unnest(${el.id})::text as id,count(*) from (${optimizedSQL})q group by unnest(${el.id}) limit 100`
|
|
61
|
+
: `select ${el.id}::text as id,count(*) from (${optimizedSQL})q group by ${el.id} limit 100`;
|
|
62
|
+
|
|
63
|
+
const countArr = await pg.queryCache(q, { table });
|
|
64
|
+
|
|
65
|
+
if (countArr.timeout) {
|
|
66
|
+
Object.assign(el, { timeout: countArr.timeout });
|
|
67
|
+
console.warn("timeout filter", table, el.id);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const ids = countArr.rows.map((el1) => el1.id);
|
|
71
|
+
|
|
72
|
+
const clsData = await getSelectVal({ pg, values: ids, name: el.data });
|
|
73
|
+
|
|
74
|
+
const options = countArr.rows.map((cel) => {
|
|
75
|
+
const data = cls?.arr?.find?.(
|
|
76
|
+
(c) => c.id?.toString?.() === cel.id?.toString?.()
|
|
77
|
+
) || { text: clsData?.[cel.id]?.text || clsData?.[cel.id] || cel.id };
|
|
78
|
+
return { ...cel, id: cel.id === null ? "null" : cel.id, ...data };
|
|
79
|
+
});
|
|
80
|
+
Object.assign(el, { options });
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { attachClassifiers } from './classifiers.js';
|
|
1
|
+
import { attachClassifiers, populateFilterOptions } from './classifiers.js';
|
|
2
2
|
import { extractVisibleColumns } from './columns.js';
|
|
3
3
|
import { getMeta, getFilterSQL } from "@opengis/fastify-table/utils.js";
|
|
4
4
|
|
|
@@ -84,6 +84,14 @@ export async function handleRegistryRequest({ settings, query, object_id, offset
|
|
|
84
84
|
if (col.view_type === 'subtitle') listConfig.subtitle = col.name;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
await populateFilterOptions({
|
|
88
|
+
pg,
|
|
89
|
+
table: table_name,
|
|
90
|
+
filters: activeFilters,
|
|
91
|
+
columns,
|
|
92
|
+
whereConditions
|
|
93
|
+
});
|
|
94
|
+
|
|
87
95
|
return {
|
|
88
96
|
register_id,
|
|
89
97
|
name,
|