updated schema to include more escalation policy and schedule data #10
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some cosmetic / comment comments, but this looks good otherwise!
pd2pg.rb
Outdated
"schedules/#{s["id"]}/users", | ||
{ since: Time.now.strftime("%Y-%m-%d") }, | ||
false) { | ||
|u| convert_user_schedule(u, s["id"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use do |u|
syntax for multiple-line blocks (with the |u|
on the same line as the do
); it gets really confusing to read otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😭
if should_log | ||
log("refresh_bulk.update", table_name: table_name, total: records.length) | ||
end | ||
database_update(table_name, records) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the addition of this, is the Yields each API value to a block
above still true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It's kind of hard to see, but the database_update
method is code I copypasted from the bottom of this method into its own method. So it's pretty much the same behavior, but "decomposed". The yield is still used!
Done addressing comments! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! \o/
Can I get permission on this repo to merge this? (Or can you merge this?) |
Summary
Pull more data from the PagerDuty v1 API. The schema now includes escalation rules and which users are in each schedule. The new tables are: escalation_rules, escalation_rule_users, escalation_rule_schedules, and user_schedule. escalation_policies also now includes a column for how many times it loops.
Motivation
We want to use this data to do more analysis on our use of PD.
Test plan
Ran on local machine and wrote SQL queries for sanity testing.
Rollout/monitoring/revert plan
None
Reviewer expectation
Comments on the schema choices would be helpful, because I wasn't sure if I was representing the PD data with the right SQL idioms.