feat(1c): derive company activity from file-base telemetry

This commit is contained in:
igor04091968
2026-05-22 10:25:09 +03:00
parent f7114bde03
commit 1ca43398a4
7 changed files with 203 additions and 17 deletions
@@ -11,12 +11,32 @@ FROM (
concat('document:', doc_type) AS event_type,
if(posted = 1, 'low', 'medium') AS severity,
if(posted = 1, 5, 20) AS score,
doc_id AS ref_id,
concat(doc_id, ':', toString(toUnixTimestamp(ts)), ':', doc_type) AS ref_id,
concat('Документ ', doc_type, '', doc_number, ' статус=', status) AS summary
FROM analytics_1c.documents
) 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,
counterparty AS entity_id,
infobase,
author AS actor,
'documents' AS source,
concat('counterparty:', operation_type) AS event_type,
if(status = 'busy', 'medium', 'low') AS severity,
greatest(10, toUInt32(round(amount))) AS score,
concat('counterparty:', counterparty, ':', doc_id, ':', toString(toUnixTimestamp(ts))) AS ref_id,
concat('Активность компании ', counterparty, ': ', doc_type, ' score=', toString(amount), ' status=', status) AS summary
FROM analytics_1c.documents
WHERE counterparty != ''
) AS src
WHERE src.ref_id NOT IN (SELECT ref_id FROM analytics_1c.entity_timeline);
INSERT INTO analytics_1c.entity_timeline
SELECT *
FROM (