<commit_before>class User < ActiveRecord::Base
  has_many :organisation_users, dependent: :destroy
  has_many :organisations, through: :organisation_users
  has_many :user_repositories, dependent: :destroy
  has_many :member_repositories, class_name: 'Repository', through: :user_repositories, source: :repository, inverse_of: :users
  has_many :owner_repositories, class_name: 'Repository', as: :owner, dependent: :destroy
  has_many :created_pull_requests, class_name: 'PullRequest', foreign_key: :created_by_id, dependent: :destroy
  has_many :merged_pull_requests, class_name: 'PullRequest', foreign_key: :merged_by_id, dependent: :destroy
  has_many :comments, dependent: :destroy, inverse_of: :user
  has_many :team_users, dependent: :destroy
  has_many :teams, through: :team_users
  has_many :scores, class_name: 'OrganisationUserScore', dependent: :destroy

  validates_presence_of :github_id, :login

  def to_param
    login
  end

  AVATAR_URL = Addressable::Template.new('https://avatars.githubusercontent.com/u/{id}{?v,s}')

  def avatar_url(size: 100, v: 3)
    AVATAR_URL.expand(id: id, s: size, v: v)
  end

  # roles, to be extracted

  def role_at?(record)
    case record
    when Organisation
      organisation_users.to_a.find { |ou| ou.organisation_id == record.id }&.role
    when Team
      team_users.to_a.find { |tu| tu.team_id == record.id }&.role
    else
      raise NotImplementedError
    end
  end
end
<commit_msg>Fixes user avatars<commit_after>class User < ActiveRecord::Base
  has_many :organisation_users, dependent: :destroy
  has_many :organisations, through: :organisation_users
  has_many :user_repositories, dependent: :destroy
  has_many :member_repositories, class_name: 'Repository', through: :user_repositories, source: :repository, inverse_of: :users
  has_many :owner_repositories, class_name: 'Repository', as: :owner, dependent: :destroy
  has_many :created_pull_requests, class_name: 'PullRequest', foreign_key: :created_by_id, dependent: :destroy
  has_many :merged_pull_requests, class_name: 'PullRequest', foreign_key: :merged_by_id, dependent: :destroy
  has_many :comments, dependent: :destroy, inverse_of: :user
  has_many :team_users, dependent: :destroy
  has_many :teams, through: :team_users
  has_many :scores, class_name: 'OrganisationUserScore', dependent: :destroy

  validates_presence_of :github_id, :login

  def to_param
    login
  end

  AVATAR_URL = Addressable::Template.new('https://avatars.githubusercontent.com/u/{id}{?v,s}')

  def avatar_url(size: 100, v: 3)
    AVATAR_URL.expand(id: github_id, s: size, v: v)
  end

  # roles, to be extracted

  def role_at?(record)
    case record
    when Organisation
      organisation_users.to_a.find { |ou| ou.organisation_id == record.id }&.role
    when Team
      team_users.to_a.find { |tu| tu.team_id == record.id }&.role
    else
      raise NotImplementedError
    end
  end
end

{'fraction_non_alphanumeric': 0.10598761183757742, 'fraction_numerical': 0.0027529249827942187, 'mean_word_length': 5.145877378435518, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '7512921', 'n_tokens_mistral': 1003, 'n_tokens_neox': 959, 'n_words': 238}