From 5302fcba003031f0fec21d3a63417a4e7f8ae63d Mon Sep 17 00:00:00 2001 From: solopiu Date: Fri, 17 Dec 2021 18:04:42 +0100 Subject: [PATCH] delete hardcoded conversion between ns and ms --- .../redshift/20211215141537_create_incidents_view.up.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/migrations/redshift/20211215141537_create_incidents_view.up.sql b/configs/migrations/redshift/20211215141537_create_incidents_view.up.sql index fcd385f..8c766fd 100644 --- a/configs/migrations/redshift/20211215141537_create_incidents_view.up.sql +++ b/configs/migrations/redshift/20211215141537_create_incidents_view.up.sql @@ -10,11 +10,11 @@ CREATE OR REPLACE VIEW watchops.incidents AS ( end as incident_id, CASE WHEN source LIKE 'github%' THEN TO_TIMESTAMP(json_extract_path_text(json_serialize(metadata), 'issue', 'created_at'), 'YYYY-MM-DD HH24:MI:SS') WHEN source LIKE 'gitlab%' THEN TO_TIMESTAMP(json_extract_path_text(json_serialize(metadata), 'object_attributes', 'created_at'), 'YYYY-MM-DD HH24:MI:SS') - WHEN source LIKE 'opsgenie' THEN dateadd(ms, CAST(json_extract_path_text(json_extract_path_text(json_serialize(metadata), 'alert'), 'createdAt') AS bigint), '1970-01-01') + WHEN source LIKE 'opsgenie' THEN dateadd(ms, CAST(json_extract_path_text(json_extract_path_text(json_serialize(metadata), 'alert'), 'createdAt') AS bigint), '1970-01-01') end as time_created, CASE WHEN source LIKE 'github%' THEN TO_TIMESTAMP(json_extract_path_text(json_serialize(metadata), 'issue', 'closed_at'), 'YYYY-MM-DD HH24:MI:SS') WHEN source LIKE 'gitlab%' THEN TO_TIMESTAMP(json_extract_path_text(json_serialize(metadata), 'object_attributes', 'closed_at'), 'YYYY-MM-DD HH24:MI:SS') - WHEN source LIKE 'opsgenie' THEN dateadd(ms, CAST(json_extract_path_text(json_extract_path_text(json_serialize(metadata), 'alert'), 'updatedAt') AS bigint)/1000000, '1970-01-01') --updatedAt is in ns + WHEN source LIKE 'opsgenie' THEN dateadd(ms, CAST(json_extract_path_text(json_extract_path_text(json_serialize(metadata), 'alert'), 'updatedAt') AS bigint), '1970-01-01') end as time_resolved, CASE WHEN source LIKE 'github%' THEN json_extract_path_text(json_serialize(metadata), 'issue', 'labels') like '%bug%' WHEN source LIKE 'gitlab%' THEN json_extract_path_text(json_serialize(metadata), 'object_attributes', 'labels','title') like '%ncident%'