From 4cccfc13770d623557df80466c3bcaf685f1c2cf Mon Sep 17 00:00:00 2001 From: Caroline Ordway Date: Tue, 8 Sep 2020 13:56:07 -0500 Subject: [PATCH 1/3] add esc policy id to service --- bin/pd2pg | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/pd2pg b/bin/pd2pg index 4d06843..28a1a5a 100755 --- a/bin/pd2pg +++ b/bin/pd2pg @@ -20,7 +20,7 @@ class PG2PD INCREMENTAL_WINDOW = 60*60*24 # Earliest time PagerDuty data could be available. - PAGERDUTY_EPOCH = Time.parse("2009-01-01T00:00Z") + PAGERDUTY_EPOCH = Time.parse("2018-01-01T00:00Z") # Reads required config from environment variables. def env!(k) @@ -64,12 +64,13 @@ class PG2PD # Send all service records from Pagerduty to database. def services_to_db(items) - columns = [:id, :name, :status, :type] + columns = [:id, :name, :status, :type, :escalation_id] records = items.map do |i| [i['id'], i['name'], i['status'], - i['type']] + i['type'], + i['escalation_policy']['id']] end database_replace(:services, columns, records) end From a8a7b30eb2e3c28a04be14ea4eba06259dfe5e44 Mon Sep 17 00:00:00 2001 From: Caroline Ordway Date: Tue, 8 Sep 2020 14:07:47 -0500 Subject: [PATCH 2/3] change date & update schema --- bin/pd2pg | 2 +- schema.sql | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/pd2pg b/bin/pd2pg index 28a1a5a..fb6ef8c 100755 --- a/bin/pd2pg +++ b/bin/pd2pg @@ -20,7 +20,7 @@ class PG2PD INCREMENTAL_WINDOW = 60*60*24 # Earliest time PagerDuty data could be available. - PAGERDUTY_EPOCH = Time.parse("2018-01-01T00:00Z") + PAGERDUTY_EPOCH = Time.parse("2009-01-01T00:00Z") # Reads required config from environment variables. def env!(k) diff --git a/schema.sql b/schema.sql index a2d62fe..88dc63b 100644 --- a/schema.sql +++ b/schema.sql @@ -28,7 +28,8 @@ create table services ( id varchar primary key, name varchar not null, status varchar not null, - type varchar not null + type varchar not null, + escalation_id varchar, ); create table escalation_policies ( From b63bfc99341a081ff6c8244e3e2a3a227c54c588 Mon Sep 17 00:00:00 2001 From: Caroline Ordway Date: Wed, 9 Sep 2020 14:50:23 -0500 Subject: [PATCH 3/3] Update schema.sql Co-authored-by: Alex Turek --- schema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema.sql b/schema.sql index 88dc63b..7cbaf7c 100644 --- a/schema.sql +++ b/schema.sql @@ -29,7 +29,7 @@ create table services ( name varchar not null, status varchar not null, type varchar not null, - escalation_id varchar, + escalation_id varchar ); create table escalation_policies (