{"size": 654, "ext": "js", "max_stars_repo_path": "packages/access-watch-ui-components/lib/components/SubscriptionSummary/utils.js", "max_stars_repo_name": "access-watch/access-watch-ui", "max_stars_repo_stars_event_min_datetime": "2018-02-02T01:06:43.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-02T01:06:43.000Z", "max_issues_repo_path": "packages/access-watch-ui-components/lib/components/SubscriptionSummary/utils.js", "max_issues_repo_name": "access-watch/access-watch-ui", "max_issues_repo_issues_event_min_datetime": "2018-02-01T17:20:19.000Z", "max_issues_repo_issues_event_max_datetime": "2019-03-30T22:36:25.000Z", "max_forks_repo_path": "packages/access-watch-ui-components/lib/components/SubscriptionSummary/utils.js", "max_forks_repo_name": "access-watch/access-watch-ui", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 89, "max_forks_count": null, "avg_line_length": 27.25, "max_line_length": 77, "alphanum_fraction": 0.5825688073}
export const getStatusType = ({ status }) => status.split('_').pop();

const statusTypeIsWorst = (a, b) => {
  if (a === b) {
    return 0;
  }
  return a === 'exceeded' ? 1 : -1;
};

const statusIsWorst = (...arr) =>
  statusTypeIsWorst(...arr.map(status => getStatusType({ status })));

export const getWorstStatus = ({ status }) =>
  status.length > 1
    ? status.reduce(
        (worst, current) => (statusIsWorst(worst, current) ? worst : current)
      )
    : status[0];

export const getStatusTypeByName = ({ status, name }) => {
  const s = status.find(tmpS => tmpS.split('_')[0] === `${name}s`);
  return s && getStatusType({ status: s });
};
