<commit_before>module AnalyticsHelper

  SCORE_WORD = ['danger', 'warning', 'success', 'empty']

  def ratings_count(ratings, total_count, score)
    count = 0
    if ratings.any?
      ratings.each do |rating|
        count += 1 if rating.score == score
      end
    end
    percent = count * 100.0 / total_count
    { count: count, percent: percent, score: score }
  end

  def no_ratings(ratings, total_count)
    count = total_count - ratings.length
    percent = count * 100.0 / total_count
    { count: count, percent: percent, score: 3 }
  end

  def render_bar(counts)
    counts[:count] = '' if counts[:count] == 0
    content_tag :div, counts[:count], class: "progress-bar progress-bar-#{SCORE_WORD[counts[:score]]}", style: "width: #{counts[:percent]}%"<commit_msg>report percent rounded to whole number instead of count<commit_after>module AnalyticsHelper

  SCORE_WORD = ['danger', 'warning', 'success', 'empty']

  def ratings_count(ratings, total_count, score)
    count = 0
    if ratings.any?
      ratings.each do |rating|
        count += 1 if rating.score == score
      end
    end
    percent = count * 100.0 / total_count
    { count: count, percent: percent, score: score }
  end

  def no_ratings(ratings, total_count)
    count = total_count - ratings.length
    percent = count * 100.0 / total_count
    { count: count, percent: percent, score: 3 }
  end

  def render_bar(counts)
    percent = counts[:count] == 0 ? '' : "#{counts[:percent].round}%"
    content_tag :div, percent, class: "progress-bar progress-bar-#{SCORE_WORD[counts[:score]]}", style: "width: #{percent}"
{'fraction_non_alphanumeric': 0.132334581772784, 'fraction_numerical': 0.0149812734082397, 'mean_word_length': 3.452777777777778, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5085203', 'n_tokens_mistral': 531, 'n_tokens_neox': 501, 'n_words': 143}