Skip to content

Commit

Permalink
PagerDuty: only get oncall for 1 escalation policy
Browse files Browse the repository at this point in the history
We might want to change this later, but for now we only have one real
escalation policy, so we'll go with this.
  • Loading branch information
mmcclimon committed Sep 23, 2021
1 parent 42bea9d commit 02a0b1c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/Synergy/Reactor/PagerDuty.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ has service_id => (
required => 1,
);

# used for getting oncall names
has escalation_policy_id => (
is => 'ro',
isa => 'Str',
required => 1,
);

has _pd_to_slack_map => (
is => 'ro',
isa => 'HashRef',
Expand Down Expand Up @@ -419,7 +426,9 @@ sub _check_long_maint ($self) {
sub _current_oncall_ids ($self) {
$self->_pd_request(GET => '/oncalls')
->then(sub ($data) {
my @oncall = map {; $_->{user} }
my $policy_id = $self->escalation_policy_id;
my @oncall = map {; $_->{user} }
grep {; $_->{escalation_policy}{id} eq $policy_id }
grep {; $_->{escalation_level} == 1}
$data->{oncalls}->@*;

Expand Down

0 comments on commit 02a0b1c

Please sign in to comment.