From 02a0b1c357e49ec91c3589c0253786d0515fefe5 Mon Sep 17 00:00:00 2001 From: Michael McClimon Date: Wed, 22 Sep 2021 21:39:32 -0400 Subject: [PATCH] PagerDuty: only get oncall for 1 escalation policy We might want to change this later, but for now we only have one real escalation policy, so we'll go with this. --- lib/Synergy/Reactor/PagerDuty.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Synergy/Reactor/PagerDuty.pm b/lib/Synergy/Reactor/PagerDuty.pm index 1e9ee753..797135b6 100644 --- a/lib/Synergy/Reactor/PagerDuty.pm +++ b/lib/Synergy/Reactor/PagerDuty.pm @@ -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', @@ -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}->@*;