{"size": 495, "ext": "js", "max_stars_repo_path": "src/store/reducers/data/ratings.selectors.js", "max_stars_repo_name": "xebia-france/conference-hall", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/store/reducers/data/ratings.selectors.js", "max_issues_repo_name": "xebia-france/conference-hall", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/store/reducers/data/ratings.selectors.js", "max_forks_repo_name": "xebia-france/conference-hall", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 35.3571428571, "max_line_length": 89, "alphanum_fraction": 0.703030303}
/* eslint-disable import/prefer-default-export */
import isEmpty from 'lodash/isEmpty'

export const getRatingsAverage = (ratings) => {
  const usersRatings = ratings.filter(r => r.feeling !== 'noopinion')
  if (isEmpty(usersRatings)) return null
  return usersRatings.map(r => r.rating).reduce((p, c) => p + c, 0) / usersRatings.length
}

export const getFeelingsCount = feeling => (ratings) => {
  if (isEmpty(ratings)) return null
  return ratings.filter(r => r.feeling === feeling).length
}
