Refactor: use data rather than series in stream callback(#18126)

This commit is contained in:
Ryan McKinley
2019-08-01 23:16:29 -07:00
committed by GitHub
parent 85da4a169d
commit 5f4b5dfecd
13 changed files with 48 additions and 48 deletions

View File

@@ -113,7 +113,7 @@ export class StreamWorker {
const maxRows = query.buffer ? query.buffer : stream.request.maxDataPoints;
// Edit the first series
const series = stream.series[0];
const series = stream.data[0];
let rows = series.rows.concat(append);
const extra = maxRows - rows.length;
if (extra < 0) {
@@ -143,7 +143,7 @@ export class SignalWorker extends StreamWorker {
constructor(key: string, query: TestDataQuery, request: DataQueryRequest, observer: DataStreamObserver) {
super(key, query, request, observer);
setTimeout(() => {
this.stream.series = [this.initBuffer(query.refId)];
this.stream.data = [this.initBuffer(query.refId)];
this.looper();
}, 10);
@@ -253,7 +253,7 @@ export class FetchWorker extends StreamWorker {
onHeader = (series: DataFrame) => {
series.refId = this.refId;
this.stream.series = [series];
this.stream.data = [series];
};
onRow = (row: any[]) => {
@@ -269,7 +269,7 @@ export class LogsWorker extends StreamWorker {
super(key, query, request, observer);
window.setTimeout(() => {
this.stream.series = [this.initBuffer(query.refId)];
this.stream.data = [this.initBuffer(query.refId)];
this.looper();
}, 10);
}

View File

@@ -13,7 +13,7 @@ import config from 'app/core/config';
import TimeSeries from 'app/core/time_series2';
import { DataFrame, DataLink } from '@grafana/data';
import { getColorFromHexRgbOrName, LegacyResponseData, VariableSuggestion } from '@grafana/ui';
import { getProcessedDataFrame } from 'app/features/dashboard/state/PanelQueryState';
import { getProcessedDataFrames } from 'app/features/dashboard/state/PanelQueryState';
import { PanelQueryRunnerFormat } from 'app/features/dashboard/state/PanelQueryRunner';
import { GraphContextMenuCtrl } from './GraphContextMenuCtrl';
import { getDataLinksVariableSuggestions } from 'app/features/panel/panellinks/link_srv';
@@ -143,7 +143,7 @@ class GraphCtrl extends MetricsPanelCtrl {
_.defaults(this.panel.xaxis, this.panelDefaults.xaxis);
_.defaults(this.panel.options, this.panelDefaults.options);
this.dataFormat = PanelQueryRunnerFormat.series;
this.dataFormat = PanelQueryRunnerFormat.frames;
this.processor = new DataProcessor(this.panel);
this.contextMenuCtrl = new GraphContextMenuCtrl($scope);
@@ -210,12 +210,12 @@ class GraphCtrl extends MetricsPanelCtrl {
// This should only be called from the snapshot callback
onDataReceived(dataList: LegacyResponseData[]) {
this.handleDataFrame(getProcessedDataFrame(dataList));
this.handleDataFrames(getProcessedDataFrames(dataList));
}
// Directly support DataFrame skipping event callbacks
handleDataFrame(data: DataFrame[]) {
super.handleDataFrame(data);
handleDataFrames(data: DataFrame[]) {
super.handleDataFrames(data);
this.dataList = data;
this.seriesList = this.processor.getSeriesList({

View File

@@ -1,5 +1,5 @@
import { DataProcessor } from '../data_processor';
import { getProcessedDataFrame } from 'app/features/dashboard/state/PanelQueryState';
import { getProcessedDataFrames } from 'app/features/dashboard/state/PanelQueryState';
describe('Graph DataProcessor', () => {
const panel: any = {
@@ -11,7 +11,7 @@ describe('Graph DataProcessor', () => {
describe('getTimeSeries from LegacyResponseData', () => {
// Try each type of data
const dataList = getProcessedDataFrame([
const dataList = getProcessedDataFrames([
{
alias: 'First (time_series)',
datapoints: [[1, 1001], [2, 1002], [3, 1003]],