feat(1c): add read-only companies export layer

This commit is contained in:
igor04091968
2026-05-22 10:46:06 +03:00
parent 31fe43f4bc
commit 02e896b05a
13 changed files with 214 additions and 17 deletions
@@ -37,6 +37,25 @@ FROM (
) AS src
WHERE src.ref_id NOT IN (SELECT ref_id FROM analytics_1c.entity_timeline);
INSERT INTO analytics_1c.entity_timeline
SELECT *
FROM (
SELECT
ts,
'counterparty' AS entity_type,
company_name AS entity_id,
infobase,
owner_user AS actor,
'companies' AS source,
'company_snapshot' AS event_type,
if(status = 'busy' OR active_locks > 0 OR temp_db_present = 1, 'medium', 'low') AS severity,
greatest(10, toUInt32(round(activity_score))) AS score,
concat('company:', infobase, ':', toString(toUnixTimestamp(ts))) AS ref_id,
concat('Company snapshot ', company_name, ': status=', status, ' locks=', toString(active_locks), ' score=', toString(activity_score)) AS summary
FROM analytics_1c.companies
) AS src
WHERE src.ref_id NOT IN (SELECT ref_id FROM analytics_1c.entity_timeline);
INSERT INTO analytics_1c.entity_timeline
SELECT *
FROM (