Skip to content

Commit

Permalink
fix: minor fix - linting errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnflank committed Sep 2, 2021
1 parent 6a46559 commit fa93109
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions src/components/Canary/aggregate.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

import { reduce } from "lodash";
import { getPercentage } from "./utils";


// if all check icons are similar in a given iconList, use that icon.
// if there are different icons, use a icon that indicate 'mixing'.
function aggregateIcon(iconList) {
Expand Down Expand Up @@ -40,27 +38,24 @@ function aggregateType(typeList) {
// calculate the average health of all checks with valid statuses
// returns a simplified list of statuses that indicates the overall health.
function aggregateStatuses(statusLists) {
const allStatuses = statusLists
.filter((item) => item !== null && item.length > 0)
.flatMap((item) => item);


const count = reduce(
statusLists,
(sum, i) => Math.max(sum, i == null ? 0 : i.length),
0
);

const aggregated = [];
for (let i = 0; i < count; i++) {
for (let i = 0; i < count; i += 1) {
const allPass = reduce(
statusLists,
(sum, list) => sum && list != null && list.length >= i && list[i] && list[i].status,
(sum, list) =>
sum && list != null && list.length >= i && list[i] && list[i].status,
true
);
const allFail = reduce(
statusLists,
(sum, list) => sum && list != null && list.length >= i && list[i] && !list[i].status,
(sum, list) =>
sum && list != null && list.length >= i && list[i] && !list[i].status,
true
);
if (allPass) {
Expand All @@ -84,16 +79,11 @@ function aggregateStatuses(statusLists) {
}

// The uptime for a group, is defined as the minimum uptime with the group
// eslint-disable-next-line no-unused-vars
function minUptime(items) {
return reduce(
items,
(old, item) => {
console.log(
old,
item,
getPercentage(old.uptime),
getPercentage(item.uptime)
);
if (getPercentage(old.uptime) > getPercentage(item.uptime)) {
return item;
}
Expand Down Expand Up @@ -123,12 +113,12 @@ function avgLatency(items) {

export function aggregate(title, items) {
if (items == null) {
return {
}
return {};
}
let _title = title
// eslint-disable-next-line no-underscore-dangle
let _title = title;
if (items.length > 1) {
_title += ` (${items.length})`
_title += ` (${items.length})`;
}
return {
description: _title,
Expand All @@ -139,5 +129,5 @@ export function aggregate(title, items) {
uptime: sumUptime(items),
checkStatuses: aggregateStatuses(items.map((item) => item.checkStatuses)),
type: aggregateType(items.map((item) => item.type))
}
};
}

0 comments on commit fa93109

Please sign in to comment.