<commit_before>class MetricsService

  attr_reader :organisation, :team

  def initialize(organisation:, team:nil, user:nil)
    @organisation = organisation
    @team = team
    @user = user
  end

  def contributions_over_time
    scope_for(OrganisationUserScore).
      group(:date).sum(:points).
      reverse_merge(date: :points)
  end

  def contributors_over_time
    scope_for(OrganisationUserScore).
      group(:date).
      order(:date).
      distinct.count(:user_id).
      reverse_merge(date: :count)
  end

  def contribution_per_contributor_over_time<commit_msg>Fixes metrics edge case<commit_after>class MetricsService

  attr_reader :organisation, :team

  def initialize(organisation:, team:nil, user:nil)
    @organisation = organisation
    @team = team
    @user = user
  end

  def contributions_over_time
    scope_for(OrganisationUserScore).
      group(:date).
      order(:date).
      sum(:points).
      reverse_merge(date: :points)
  end

  def contributors_over_time
    scope_for(OrganisationUserScore).
      group(:date).
      order(:date).
      distinct.count(:user_id).
      reverse_merge(date: :count)
  end

  def contribution_per_contributor_over_time
{'fraction_non_alphanumeric': 0.09388097233864208, 'fraction_numerical': 0.0, 'mean_word_length': 3.574712643678161, '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': '4416506', 'n_tokens_mistral': 371, 'n_tokens_neox': 360, 'n_words': 72}