Commit b39268f1 by Torkel Ödegaard

Explore: ResultProcessor refactor isTimeSeries check

parents 6e6e2c96 289a33bf
...@@ -274,8 +274,6 @@ export class PanelQueryState { ...@@ -274,8 +274,6 @@ export class PanelQueryState {
return { return {
state: done ? LoadingState.Done : LoadingState.Streaming, state: done ? LoadingState.Done : LoadingState.Streaming,
// This should not be needed but unfortunately Prometheus datasource sends non DataFrame here bypassing the
// typing.
series: this.sendFrames ? getProcessedDataFrames(series) : [], series: this.sendFrames ? getProcessedDataFrames(series) : [],
legacy: this.sendLegacy ? translateToLegacyData(series) : undefined, legacy: this.sendLegacy ? translateToLegacyData(series) : undefined,
request: { request: {
......
...@@ -18,7 +18,7 @@ export class ResultProcessor { ...@@ -18,7 +18,7 @@ export class ResultProcessor {
return []; return [];
} }
const onlyTimeSeries = this.dataFrames.filter(series => series.fields.length === 2); const onlyTimeSeries = this.dataFrames.filter(isTimeSeries);
return getGraphSeriesModel( return getGraphSeriesModel(
onlyTimeSeries, onlyTimeSeries,
...@@ -36,14 +36,7 @@ export class ResultProcessor { ...@@ -36,14 +36,7 @@ export class ResultProcessor {
// For now ignore time series // For now ignore time series
// We can change this later, just need to figure out how to // We can change this later, just need to figure out how to
// Ignore time series only for prometheus // Ignore time series only for prometheus
const onlyTables = this.dataFrames.filter(frame => { const onlyTables = this.dataFrames.filter(frame => !isTimeSeries(frame));
if (frame.fields.length === 2) {
if (frame.fields[1].type === FieldType.time) {
return false;
}
}
return true;
});
const tables = onlyTables.map(frame => { const tables = onlyTables.map(frame => {
const { fields } = frame; const { fields } = frame;
...@@ -113,3 +106,13 @@ export class ResultProcessor { ...@@ -113,3 +106,13 @@ export class ResultProcessor {
return { ...sortedNewResults, rows, series }; return { ...sortedNewResults, rows, series };
} }
} }
export function isTimeSeries(frame: DataFrame): boolean {
if (frame.fields.length === 2) {
if (frame.fields[1].type === FieldType.time) {
return true;
}
}
return false;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment