Skip to content

Commit

Permalink
Use roundInterval from @grafana/data package, fix #1142
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderzobnin committed Jan 20, 2021
1 parent 5754364 commit 4556f90
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import { ZBX_ACK_ACTION_NONE, ZBX_ACK_ACTION_ADD_MESSAGE, MIN_SLA_INTERVAL } fro
import { ShowProblemTypes, ZBXProblem } from '../../../types';
import { JSONRPCError, ZBXScript, APIExecuteScriptResponse } from './types';
import { BackendSrvRequest, getBackendSrv } from '@grafana/runtime';
import { rangeUtil } from '@grafana/data';

const DEFAULT_ZABBIX_VERSION = '3.0.0';

// Backward compatibility. Since Grafana 7.2 roundInterval() func was moved to @grafana/data package
const roundInterval: (interval: number) => number = rangeUtil?.roundInterval || kbn.roundInterval || kbn.round_interval;

/**
* Zabbix API Wrapper.
* Creates Zabbix API instance with given parameters (url, credentials and other).
Expand Down Expand Up @@ -680,7 +684,7 @@ function filterTriggersByAcknowledge(triggers, acknowledged) {
function getSLAInterval(intervalMs) {
// Too many intervals may cause significant load on the database, so decrease number of resulting points
const resolutionRatio = 100;
const interval = kbn.round_interval(intervalMs * resolutionRatio) / 1000;
const interval = roundInterval(intervalMs * resolutionRatio) / 1000;
return Math.max(interval, MIN_SLA_INTERVAL);
}

Expand Down

0 comments on commit 4556f90

Please sign in to comment.