@opengis/admin 0.2.118 → 0.2.120

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.
@@ -30,22 +30,37 @@ export default async function widgetGet({
30
30
  where entity_id=$1 order by cdate desc`
31
31
  : 'select communication_id, entity_id, body, subject, cdate, uid from crm.communications where entity_id=$1 order by cdate desc',
32
32
 
33
- history: `SELECT change_id, entity_id, entity_type, change_type, change_date, a.change_user_id, a.uid, a.cdate, b.json_agg as changes,
34
- ${username} as username, u.login, u.avatar
35
- FROM log.table_changes a
36
- left join admin.users u on a.change_user_id = u.uid
37
- left join lateral(
38
- select json_agg(row_to_json(q)) from (
39
- select change_data_id, entity_key, value_new, value_old from log.table_changes_data
40
- where change_id=a.change_id
41
- )q
42
- )b on 1=1
43
- where (entity_id=$1 or entity_id in (
44
- select communication_id as comments from crm.communications where entity_id=$1
45
- union all select file_id from crm.files where entity_id=$1
46
- union all select checklist_id from crm.checklists where entity_id=$1)
47
- ) order by cdate desc
48
- limit 100`,
33
+ history: `select * from (
34
+ SELECT change_id, entity_id, entity_type, change_type, change_date, a.change_user_id, a.uid, a.cdate, b.json_agg as changes,
35
+ ${username} as username, u.login, u.avatar
36
+ FROM log.table_changes a
37
+ left join admin.users u on a.change_user_id = u.uid
38
+ left join lateral(
39
+ select json_agg(row_to_json(q)) from (
40
+ select change_data_id, entity_key, value_new, value_old from log.table_changes_data
41
+ where change_id=a.change_id
42
+ )q
43
+ )b on 1=1
44
+ where b.json_agg is not null and (entity_id=$1 or entity_id in (
45
+ select communication_id as comments from crm.communications where entity_id=$1
46
+ union all select checklist_id from crm.checklists where entity_id=$1)
47
+ )
48
+
49
+ union all
50
+ select change_id, entity_id, entity_type, change_type, change_date, a.change_user_id, a.uid, a.cdate, b.json_agg as changes,
51
+ ${username} as username, u.login, u.avatar
52
+ FROM log.table_changes a
53
+ left join admin.users u on a.change_user_id = u.uid
54
+ left join lateral(
55
+ select json_agg(o) from (
56
+ select json_object_agg(entity_key, coalesce(value_new, value_old)) as o from log.table_changes_data
57
+ where change_id=a.change_id and entity_key not in ('uid', 'file_status', 'editor_id', 'cdate', 'editor_date', 'entity_id')
58
+ )q
59
+ )b on 1=1
60
+ where a.change_type in ('INSERT', 'DELETE') and a.entity_id in (select file_id from crm.files where entity_id=$1)
61
+ limit 100
62
+
63
+ )q order by cdate desc limit 100`,
49
64
 
50
65
  checklist: pg.pk['admin.users']
51
66
  ? `SELECT checklist_id, entity_id, subject, is_done, done_date, c.uid, c.cdate, ${username} as username, u.login, u.avatar