catch undefined and return default empty in normalizeMetrics

Signed-off-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
Sebastian Malton committed 2020-06-15 12:02:29 -04:00
1 parent 8f0c785f58
commit 2b90d130c2
5 files changed
+31 -16

No files matched your search

@@ -56,7 +56,21 @@ export const metricsApi = {
};
export function normalizeMetrics(metrics: IMetrics, frames = 60): IMetrics {
if (!metrics?.data?.result) {
return {
data: {
resultType: "",
result: [{
metric: {},
values: []
} as IMetricsResult],
},
status: "",
}
}
const { result } = metrics.data;
if (result.length) {
if (frames > 0) {
// fill the gaps