<commit_before>class GithubOrganisation < ActiveRecord::Base
  API_FIELDS = [:name, :login, :blog, :email, :location, :description]

  has_many :github_repositories
  has_many :source_github_repositories, -> { where fork: false }, anonymous_class: GithubRepository
  has_many :dependencies, through: :source_github_repositories
  has_many :favourite_projects, -> { group('projects.id').order("COUNT(projects.id) DESC") }, through: :dependencies, source: :project
  has_many :contributors, -> { group('github_users.id').order("COUNT(github_users.id) DESC") }, through: :github_repositories, source: :contributors

  validates_uniqueness_of :github_id, :login

  after_commit :download_repos, on: :create

  scope :most_repos, -> { joins(:source_github_repositories).select('github_organisations.*, count(github_repositories.id) AS repo_count').group('github_organisations.id').order('repo_count DESC') }
  scope :most_stars, -> { joins(:source_github_repositories).select('github_organisations.*, sum(github_repositories.stargazers_count) AS star_count, count(github_repositories.id) AS repo_count').group('github_organisations.id').order('star_count DESC') }
  scope :newest, -> { joins(:source_github_repositories).select('github_organisations.*, count(github_repositories.id) AS repo_count').group('github_organisations.id').order('created_at DESC').having('count(github_repositories.id) > 0') }<commit_msg>Only consider open source repos on the orgs page<commit_after>class GithubOrganisation < ActiveRecord::Base
  API_FIELDS = [:name, :login, :blog, :email, :location, :description]

  has_many :github_repositories
  has_many :source_github_repositories, -> { where fork: false }, anonymous_class: GithubRepository
  has_many :open_source_github_repositories, -> { where fork: false, private: false }, anonymous_class: GithubRepository
  has_many :dependencies, through: :source_github_repositories
  has_many :favourite_projects, -> { group('projects.id').order("COUNT(projects.id) DESC") }, through: :dependencies, source: :project
  has_many :contributors, -> { group('github_users.id').order("COUNT(github_users.id) DESC") }, through: :github_repositories, source: :contributors

  validates_uniqueness_of :github_id, :login

  after_commit :download_repos, on: :create

  scope :most_repos, -> { joins(:open_source_github_repositories).select('github_organisations.*, count(github_repositories.id) AS repo_count').group('github_organisations.id').order('repo_count DESC') }
  scope :most_stars, -> { joins(:open_source_github_repositories).select('github_organisations.*, sum(github_repositories.stargazers_count) AS star_count, count(github_repositories.id) AS repo_count').group('github_organisations.id').order('star_count DESC') }
  scope :newest, -> { joins(:open_source_github_repositories).select('github_organisations.*, count(github_repositories.id) AS repo_count').group('github_organisations.id').order('created_at DESC').having('count(github_repositories.id) > 0') }
{'fraction_non_alphanumeric': 0.13549682167949148, 'fraction_numerical': 0.0006691201070592171, 'mean_word_length': 8.228395061728396, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6624968', 'n_tokens_mistral': 973, 'n_tokens_neox': 894, 'n_words': 159}