revision.ts 537 B

12345678910111213141516
  1. import { compareArrayValues, compareDataFrameStructures, PanelData } from '@grafana/data';
  2. export const setStructureRevision = (result: PanelData, lastResult: PanelData | undefined) => {
  3. let structureRev = 1;
  4. if (lastResult?.structureRev && lastResult.series) {
  5. structureRev = lastResult.structureRev;
  6. const sameStructure = compareArrayValues(result.series, lastResult.series, compareDataFrameStructures);
  7. if (!sameStructure) {
  8. structureRev++;
  9. }
  10. }
  11. result.structureRev = structureRev;
  12. return result;
  13. };