@opengis/fastify-table 1.1.18 → 1.1.20

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/Changelog.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # fastify-table
2
2
 
3
- ## 1.1.18 - 01.10.2024
3
+ ## 1.1.20 - 02.10.2024
4
+
5
+ - code optimization
6
+
7
+ ## 1.1.19 - 01.10.2024
4
8
 
5
9
  - custom hook support - addHook, applyHook
6
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "1.1.18",
3
+ "version": "1.1.20",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "main": "index.js",
@@ -20,7 +20,10 @@ async function getFilterSQL({
20
20
 
21
21
  const sqlList = body?.sql?.length
22
22
  ? body?.sql?.filter((el) => !el.disabled && el?.sql?.replace)
23
- .map((el) => ` left join lateral (${el.filter ? el.sql.replace(/limit 1/ig, '') : el.sql}) as ${el.name} on 1=1 `).join(' ')
23
+ .map((el, i) => {
24
+ Object.assign(el, { name: el.name || `t${i + 1}` });
25
+ return ` left join lateral (${el.filter ? el.sql.replace(/limit 1/ig, '') : el.sql}) as ${el.name} on 1=1 `;
26
+ }).join(' ')
24
27
  : '';
25
28
  const fieldQuery = config.allTemplates?.table?.[table] ? `${config.allTemplates?.table?.[table]} limit 0`
26
29
  : `select * from ${body?.table || table} ${sqlList ? ` t ${sqlList}` : ''} where 1=1 limit 0`;
@@ -33,7 +33,11 @@ export default async function widgetGet({
33
33
  left join lateral(
34
34
  select change_data_id, entity_key, value_new, value_old from log.table_changes_data where change_id=a.change_id
35
35
  )b on 1=1
36
- where entity_id=$1 and b.change_data_id is not null order by cdate desc limit 100`,
36
+ where (entity_id=$1 or entity_id in (
37
+ select communication_id as comments from crm.communications where entity_id=$1
38
+ union all select file_id from crm.files where entity_id=$1
39
+ union all select checklist_id from crm.checklists where entity_id=$1)
40
+ ) and b.change_data_id is not null order by cdate desc limit 100`,
37
41
 
38
42
  checklist: pg.pk['admin.users']
39
43
  ? `SELECT checklist_id, entity_id, subject, is_done, done_date, c.uid, c.cdate, coalesce(user_name,' ')||' '||coalesce(sur_name,'') as username,