<commit_before>class Repo < ActiveRecord::Base

  validate :github_url_exists, :on => :create
  after_create :populate_issues!, :update_repo_info!

  before_validation :downcase_name

  validates :name, :user_name, :presence => true
  validates :name, :uniqueness => {:scope => :user_name}

  has_many :issues
  has_many :repo_subscriptions
  has_many :users, :through => :repo_subscriptions

  def subscriber_count
    users.count
  end

  # pulls out number of issues divided by number of subscribers
  def self.order_by_need
     joins(:repo_subscriptions).order("issues_count::float/COUNT(repo_subscriptions.repo_id) DESC").group("repos.id")
  end

  def self.not_in(*ids)
    where("repos.id not in (?)", ids)
  end

  def self.rand
    order("random()")
  end

  def force_issues_count_sync!
     self.update_attributes(issues_count: self.issues.where(state: "open").count)
  end

  def to_param
    username_repo
  end

  def downcase_name<commit_msg>find all repos with no subscribers<commit_after>class Repo < ActiveRecord::Base

  validate :github_url_exists, :on => :create
  after_create :populate_issues!, :update_repo_info!

  before_validation :downcase_name

  validates :name, :user_name, :presence => true
  validates :name, :uniqueness => {:scope => :user_name}

  has_many :issues
  has_many :repo_subscriptions
  has_many :users, :through => :repo_subscriptions

  def subscriber_count
    users.count
  end

  # pulls out number of issues divided by number of subscribers
  def self.order_by_need
     joins(:repo_subscriptions).order("issues_count::float/COUNT(repo_subscriptions.repo_id) DESC").group("repos.id")
  end

  # these repos have no subscribers and have no buisness being in our database
  def self.inactive
    joins("LEFT OUTER JOIN repo_subscriptions on repos.id = repo_subscriptions.repo_id").where("repo_subscriptions.repo_id is null")
  end

  def self.not_in(*ids)
    where("repos.id not in (?)", ids)
  end

  def self.rand
    order("random()")
  end

  def force_issues_count_sync!
     self.update_attributes(issues_count: self.issues.where(state: "open").count)
  end

  def to_param
    username_repo
  end

  def downcase_name
{'fraction_non_alphanumeric': 0.09880514705882353, 'fraction_numerical': 0.0, 'mean_word_length': 4.483627204030227, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '2311543', 'n_tokens_mistral': 741, 'n_tokens_neox': 695, 'n_words': 173}