2020-04-21 14:21:52 +00:00
|
|
|
import { helper } from '@ember/component/helper';
|
|
|
|
|
|
|
|
export function healthChecks([items], hash) {
|
|
|
|
let ChecksCritical = 0;
|
|
|
|
let ChecksWarning = 0;
|
|
|
|
let ChecksPassing = 0;
|
|
|
|
|
|
|
|
items.forEach(item => {
|
|
|
|
switch (item.Status) {
|
|
|
|
case 'critical':
|
|
|
|
ChecksCritical += 1;
|
|
|
|
break;
|
|
|
|
case 'warning':
|
|
|
|
ChecksWarning += 1;
|
|
|
|
break;
|
|
|
|
case 'passing':
|
|
|
|
ChecksPassing += 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
switch (true) {
|
|
|
|
case ChecksCritical !== 0:
|
2020-06-16 15:59:31 +00:00
|
|
|
return {
|
|
|
|
status: 'failing',
|
|
|
|
count: ChecksCritical,
|
|
|
|
};
|
2020-04-21 14:21:52 +00:00
|
|
|
case ChecksWarning !== 0:
|
2020-06-16 15:59:31 +00:00
|
|
|
return {
|
|
|
|
status: 'warning',
|
|
|
|
count: ChecksWarning,
|
|
|
|
};
|
2020-04-21 14:21:52 +00:00
|
|
|
case ChecksPassing !== 0:
|
2020-06-16 15:59:31 +00:00
|
|
|
return {
|
|
|
|
status: 'passing',
|
|
|
|
count: ChecksPassing,
|
|
|
|
};
|
2020-04-21 14:21:52 +00:00
|
|
|
default:
|
2020-06-16 15:59:31 +00:00
|
|
|
return {
|
|
|
|
status: 'empty',
|
|
|
|
};
|
2020-04-21 14:21:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default helper(healthChecks);
|