<commit_before>class User < ActiveRecord::Base
  belongs_to :article
  has_many :articles, foreign_key: "author_id"
  has_many :subscriptions, class_name: "ArticleSubscription"
  has_many :subscribed_articles, :through => :subscriptions, source: :articles

  has_many :edits, class_name: "Article", foreign_key: "editor_id"

  domain_regex = /\A([\w\.%\+\-]+)@(codeschool)\.com$\z/
  validates :email, presence: true, format: { with: domain_regex }

  mount_uploader :avatar, AvatarUploader

  def self.author
    joins(:articles).group('users.id').having('count(articles.id) > 0')
  end

  def self.prolific
    joins(articles: :author).
      select('users.*, count(articles.id) as articles_count').
      group('users.id').
      order('articles_count DESC')
  end

  def self.active
    where(active: true)
  end

  def self.find_or_create_from_omniauth(auth)
    if user = where(auth.slice("provider", "uid")).first
      # Only update the user's image if they don't already have one.<commit_msg>Fix association source for User's subscribed_articles.<commit_after>class User < ActiveRecord::Base
  belongs_to :article
  has_many :articles, foreign_key: "author_id"
  has_many :subscriptions, class_name: "ArticleSubscription"
  has_many :subscribed_articles, through: :subscriptions, source: :article

  has_many :edits, class_name: "Article", foreign_key: "editor_id"

  domain_regex = /\A([\w\.%\+\-]+)@(codeschool)\.com$\z/
  validates :email, presence: true, format: { with: domain_regex }

  mount_uploader :avatar, AvatarUploader

  def self.author
    joins(:articles).group('users.id').having('count(articles.id) > 0')
  end

  def self.prolific
    joins(articles: :author).
      select('users.*, count(articles.id) as articles_count').
      group('users.id').
      order('articles_count DESC')
  end

  def self.active
    where(active: true)
  end

  def self.find_or_create_from_omniauth(auth)
    if user = where(auth.slice("provider", "uid")).first
      # Only update the user's image if they don't already have one.
{'fraction_non_alphanumeric': 0.13536047081902894, 'fraction_numerical': 0.000980872976949485, 'mean_word_length': 4.3125, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '3554329', 'n_tokens_mistral': 709, 'n_tokens_neox': 657, 'n_words': 156}