grafana/public/app/features/query/state/processing/revision.ts
Peter Holmberg 0006765a40
Alerting: Run queries (#33423)
* alertingqueryrunner first edition

* added so we always set name and uid when changing datasource.

* wip.

* wip

* added support for canceling requests.

* util for getting time ranges for expression queries

* remove logs, store data in state

* added structure for marble testing.

* change so the expression buttons doesnt submit form.

* fixed run button.

* replaced mocks with implementation that will set default query + expression.

* fixed so we set a datasource name for the default expression rule.

* improving expression guard.

* Update public/app/features/alerting/components/AlertingQueryEditor.tsx

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>

* fixed some nits.

* some refactoring after feedback.

* use grafanthemev2

* rename grafanatheme

* fixing so we convert to correct relative time range.

* added some more tests.

* fixing so duplicating query works.

* added some more tests without marbles.

* small refactoring to share code between runRequest and alerting query runner.

Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-05-04 16:31:25 +02:00

17 lines
537 B
TypeScript

import { compareArrayValues, compareDataFrameStructures, PanelData } from '@grafana/data';
export const setStructureRevision = (result: PanelData, lastResult: PanelData | undefined) => {
let structureRev = 1;
if (lastResult?.structureRev && lastResult.series) {
structureRev = lastResult.structureRev;
const sameStructure = compareArrayValues(result.series, lastResult.series, compareDataFrameStructures);
if (!sameStructure) {
structureRev++;
}
}
result.structureRev = structureRev;
return result;
};