add timezone to queries and sort oncalls
This commit is contained in:
@@ -46,7 +46,7 @@ export class PagerDutyClient implements PagerDutyApi {
|
||||
constructor(private readonly config: ClientApiConfig) {}
|
||||
|
||||
async getServiceByIntegrationKey(integrationKey: string): Promise<Service[]> {
|
||||
const params = `include[]=integrations&include[]=escalation_policies&query=${integrationKey}`;
|
||||
const params = `time_zone=UTC&include[]=integrations&include[]=escalation_policies&query=${integrationKey}`;
|
||||
const url = `${await this.config.discoveryApi.getBaseUrl(
|
||||
'proxy',
|
||||
)}/pagerduty/services?${params}`;
|
||||
@@ -56,7 +56,7 @@ export class PagerDutyClient implements PagerDutyApi {
|
||||
}
|
||||
|
||||
async getIncidentsByServiceId(serviceId: string): Promise<Incident[]> {
|
||||
const params = `statuses[]=triggered&statuses[]=acknowledged&service_ids[]=${serviceId}`;
|
||||
const params = `time_zone=UTC&sort_by=created_at&statuses[]=triggered&statuses[]=acknowledged&service_ids[]=${serviceId}`;
|
||||
const url = `${await this.config.discoveryApi.getBaseUrl(
|
||||
'proxy',
|
||||
)}/pagerduty/incidents?${params}`;
|
||||
@@ -66,7 +66,7 @@ export class PagerDutyClient implements PagerDutyApi {
|
||||
}
|
||||
|
||||
async getOnCallByPolicyId(policyId: string): Promise<OnCall[]> {
|
||||
const params = `include[]=users&escalation_policy_ids[]=${policyId}`;
|
||||
const params = `time_zone=UTC&include[]=users&escalation_policy_ids[]=${policyId}&include[]=escalation_level`;
|
||||
const url = `${await this.config.discoveryApi.getBaseUrl(
|
||||
'proxy',
|
||||
)}/pagerduty/oncalls?${params}`;
|
||||
|
||||
@@ -32,7 +32,9 @@ export const EscalationPolicy = ({ policyId }: Props) => {
|
||||
|
||||
const { value: users, loading, error } = useAsync(async () => {
|
||||
const oncalls = await api.getOnCallByPolicyId(policyId);
|
||||
const users = oncalls.map(oncall => oncall.user);
|
||||
const users = oncalls
|
||||
.sort((a, b) => a.escalation_level - b.escalation_level)
|
||||
.map(oncall => oncall.user);
|
||||
|
||||
return users;
|
||||
});
|
||||
|
||||
@@ -41,6 +41,7 @@ export type Service = {
|
||||
|
||||
export type OnCall = {
|
||||
user: User;
|
||||
escalation_level: number;
|
||||
};
|
||||
|
||||
export type Assignee = {
|
||||
|
||||
Reference in New Issue
Block a user