@opengis/bi 1.0.42 → 1.0.43

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": "@opengis/bi",
3
- "version": "1.0.42",
3
+ "version": "1.0.43",
4
4
  "description": "BI data visualization module",
5
5
  "main": "dist/bi.js",
6
6
  "browser": "dist/bi.umd.cjs",
@@ -93,6 +93,7 @@ alter table bi.cluster alter column cluster_id set default next_id();
93
93
  alter table bi.cluster alter column cluster_id set default next_id();
94
94
  ALTER TABLE bi.cluster ADD COLUMN IF NOT EXISTS title text;
95
95
  ALTER TABLE bi.cluster ADD COLUMN IF NOT EXISTS type text;
96
+ ALTER TABLE bi.cluster ADD COLUMN IF NOT EXISTS codifier text;
96
97
  ALTER TABLE bi.cluster ADD COLUMN IF NOT EXISTS geom geometry(MultiPolygon,4326);
97
98
 
98
99
  ALTER TABLE bi.cluster ADD COLUMN IF NOT EXISTS uid text;
@@ -1,4 +1,4 @@
1
- import { logger, pgClients } from '@opengis/fastify-table/utils.js';
1
+ import { config, logger, pgClients } from '@opengis/fastify-table/utils.js';
2
2
 
3
3
  export default async function downloadClusterData({ pg = pgClients.client, cluster }) {
4
4
  if (!pg || !cluster) return null;
@@ -24,12 +24,12 @@ export default async function downloadClusterData({ pg = pgClients.client, clust
24
24
  }
25
25
  const { count = 0 } = await pg.query(`select count(*)::int from bi.cluster where type=$1`, [cluster])
26
26
  .then((res1) => res1.rows?.[0] || {});
27
- if (count !== features?.length) {
27
+ if (count !== features?.length || config.debug) {
28
28
  // await pg.query(`delete from bi.cluster where type=$1`, [cluster]);
29
- const values = features?.map((el) => `('${el.properties.name?.replace(/'/g, "''") || ''}', '${cluster}', ST_GeomFromGeoJSON('${JSON.stringify(el.geometry)}')::geometry)`).join(',');
29
+ const values = features?.map((el) => `('${el.properties.codifier?.replace(/'/g, "''") || ''}','${el.properties.name?.replace(/'/g, "''") || ''}', '${cluster}', ST_GeomFromGeoJSON('${JSON.stringify(el.geometry)}')::geometry)`).join(',');
30
30
 
31
- const { rowCount } = await pg.query(`insert into bi.cluster (title,type,geom)
32
- values ${values} on conflict(title,type) do update set geom=excluded.geom`);
31
+ const { rowCount } = await pg.query(`insert into bi.cluster (codifier,title,type,geom)
32
+ values ${values} on conflict(title,type) do update set codifier=excluded.codifier, geom=excluded.geom`);
33
33
  logger.file('bi/clusterVtile', { cluster, rowCount });
34
34
  }
35
35
  } catch (err) {