mirror of
https://github.com/yldio/copilot.git
synced 2024-11-14 23:30:05 +02:00
fix(cp-frontend): handle no previous metrics
This commit is contained in:
parent
0d659c94e8
commit
d9ae6eb34a
@ -55,7 +55,13 @@ export const withServiceMetricsGql = ({
|
|||||||
instanceId,
|
instanceId,
|
||||||
metricName
|
metricName
|
||||||
) => {
|
) => {
|
||||||
const service = find(get(previousResult, 'deploymentGroup.services', []), [
|
const services = get(previousResult, 'deploymentGroup.services', []);
|
||||||
|
|
||||||
|
if (!services.length) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const service = find(services, [
|
||||||
'id',
|
'id',
|
||||||
serviceId
|
serviceId
|
||||||
]);
|
]);
|
||||||
@ -64,9 +70,19 @@ export const withServiceMetricsGql = ({
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return service.instances
|
const instance = find(service.instances, ['id', instanceId]);
|
||||||
.find(i => i.id === instanceId)
|
|
||||||
.metrics.find(m => m.name === metricName).metrics;
|
if (!instance) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const metrics = find(instance.metrics, ['name', metricName]);
|
||||||
|
|
||||||
|
if (!metrics) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return get(metrics, 'metrics', []);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getNextResult = (previousResult, fetchNextResult) => {
|
const getNextResult = (previousResult, fetchNextResult) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user