gitlab-org--gitlab-foss/app/assets/javascripts/helpers/monitor_helper.js
Adriel Santiago 239aa51438 Restore multiple series support
Corrects an issue whereby queries which return multiple series results
were not rendering as multiple data series on the metrics dashboard
2019-04-05 09:14:13 +00:00

17 lines
578 B
JavaScript

/* eslint-disable import/prefer-default-export */
export const makeDataSeries = (queryResults, defaultConfig) =>
queryResults.reduce((acc, result) => {
const data = result.values.filter(([, value]) => !Number.isNaN(value));
if (!data.length) {
return acc;
}
const relevantMetric = defaultConfig.name.toLowerCase().replace(' ', '_');
const name = result.metric[relevantMetric];
const series = { data };
if (name) {
series.name = `${defaultConfig.name}: ${name}`;
}
return acc.concat({ ...defaultConfig, ...series });
}, []);