Explore: show meta data when available (#25798)

* Return valid metadata even if data is empty

* Make sure fields is not accessed when there is no data

* Meta Info should depend only on meta data

* Refactor condition for better reading

* Change data to empty array for better condition handling

* Remove unecessary checks

* Add test for showing metaData even when data is empty
This commit is contained in:
Besart Berisha
2020-07-17 10:30:27 +02:00
committed by GitHub
parent 7a11ed91cb
commit 373e869652
6 changed files with 89 additions and 31 deletions

View File

@@ -312,22 +312,36 @@ export function lokiStreamsToDataframes(
lokiQueryStatKey: 'Summary: total bytes processed',
};
const meta: QueryResultMeta = {
searchWords: getHighlighterExpressionsFromQuery(formatQuery(target.expr)),
limit,
stats,
custom,
preferredVisualisationType: 'logs',
};
const series: DataFrame[] = data.map(stream => {
const dataFrame = lokiStreamResultToDataFrame(stream, reverse);
enhanceDataFrame(dataFrame, config);
return {
...dataFrame,
refId: target.refId,
meta: {
searchWords: getHighlighterExpressionsFromQuery(formatQuery(target.expr)),
limit,
stats,
custom,
preferredVisualisationType: 'logs',
},
meta,
};
});
if (stats.length && !data.length) {
return [
{
fields: [],
length: 0,
refId: target.refId,
meta,
},
];
}
return series;
}