@opengis/bi 1.0.31 → 1.0.32

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.31",
3
+ "version": "1.0.32",
4
4
  "description": "BI data visualization module",
5
5
  "main": "dist/bi.js",
6
6
  "browser": "dist/bi.umd.cjs",
@@ -82,10 +82,10 @@ export default async function cluster(req) {
82
82
  ? await getFilterSQL({ pg, table, filter, search })
83
83
  : {};
84
84
 
85
- const q = `select "${cluster}" as name, sum("${metrics[0]}")::float as metric
85
+ const q = `select b.*, ${clusterTable?.operator || 'sum'}("${metrics[0]}")::float as metric
86
86
  from ${optimizedSQL ? `(${optimizedSQL})` : table} q
87
- left join lateral (select "${pg.pk?.[clusterTable?.name]}" as id from ${clusterTable?.name} where ${clusterTable?.title}=q."${cluster}" limit 1)b on 1=1
88
- where ${where} group by ${cluster}, b.id order by sum("${metrics[0]}")::float desc`;
87
+ left join lateral (select "${pg.pk?.[clusterTable?.name]}" as id, ${clusterTable?.column || cluster} as name, ${clusterTable?.title} as title from ${clusterTable?.name} where ${clusterTable?.codifierColumn || 'codifier'}=q."${clusterTable?.column || cluster}" limit 1)b on 1=1
88
+ where ${where} group by b.id, b.name, b.title order by ${clusterTable?.operator || 'sum'}("${metrics[0]}")::float desc`;
89
89
 
90
90
  if (query.sql === '1') return q;
91
91