<commit_before>class GithubRepositoriesController < ApplicationController
  def index
    @language = Languages::Language[params[:language]] if params[:language].present?
    @license = Spdx.find(params[:license]) if params[:license].present?

    postfix = [@language, @license.try(:id)].compact.any? ? 'Repos' : 'Repositories'
    @title = [@language, @license.try(:id), postfix].compact.join(' ')

    orginal_scope = GithubRepository.open_source.source.where.not(pushed_at: nil)
    language_scope = @language.present? ? orginal_scope.where('lower(language) = ?', @language.name.downcase) : orginal_scope
    license_scope = @license.present? ? orginal_scope.where('lower(license) = ?', @license.id.downcase) : orginal_scope
    scope = @license.present? ? language_scope.where('lower(license) = ?', @license.id.downcase) : language_scope

    @popular = scope.where('stargazers_count > 0').order('stargazers_count DESC').limit(6)
    @forked = scope.where('forks_count > 0').order('forks_count DESC').limit(6)
    @created = scope.order('created_at DESC').limit(6)
    @updated = scope.order('pushed_at DESC').limit(6)

    @languages = license_scope.group('lower(language)').count.reject{|k,v| k.blank? }.sort_by{|k,v| v }.reverse.first(30)
    @licenses = language_scope.group('lower(license)').count.reject{|k,v| k.blank? || k == 'other' }.sort_by{|k,v| v }.reverse.first(30)
  end

  def show
    load_repo
    @contributors = @github_repository.github_contributions.order('count DESC').limit(20).includes(:github_user)
    @projects = @github_repository.projects
    @color = @github_repository.color
  end

  def contributors
    load_repo
    @contributors = @github_repository.github_contributions.order('count DESC').includes(:github_user).paginate(page: params[:page])
  end

  def load_repo
    full_name = [params[:owner], params[:name]].join('/')
    @github_repository = GithubRepository.where(full_name: full_name).first
    @github_repository = GithubRepository.where('lower(full_name) = ?', full_name.downcase).first if @github_repository.nil?
    raise ActiveRecord::RecordNotFound if @github_repository.nil?
    raise ActiveRecord::RecordNotFound unless authorized?<commit_msg>Show even more github languages<commit_after>class GithubRepositoriesController < ApplicationController
  def index
    @language = Languages::Language[params[:language]] if params[:language].present?
    @license = Spdx.find(params[:license]) if params[:license].present?

    postfix = [@language, @license.try(:id)].compact.any? ? 'Repos' : 'Repositories'
    @title = [@language, @license.try(:id), postfix].compact.join(' ')

    orginal_scope = GithubRepository.open_source.source.where.not(pushed_at: nil)
    language_scope = @language.present? ? orginal_scope.where('lower(language) = ?', @language.name.downcase) : orginal_scope
    license_scope = @license.present? ? orginal_scope.where('lower(license) = ?', @license.id.downcase) : orginal_scope
    scope = @license.present? ? language_scope.where('lower(license) = ?', @license.id.downcase) : language_scope

    @popular = scope.where('stargazers_count > 0').order('stargazers_count DESC').limit(6)
    @forked = scope.where('forks_count > 0').order('forks_count DESC').limit(6)
    @created = scope.order('created_at DESC').limit(6)
    @updated = scope.order('pushed_at DESC').limit(6)

    @languages = license_scope.group('lower(language)').count.reject{|k,v| k.blank? }.sort_by{|k,v| v }.reverse.first(40)
    @licenses = language_scope.group('lower(license)').count.reject{|k,v| k.blank? || k == 'other' }.sort_by{|k,v| v }.reverse.first(25)
  end

  def show
    load_repo
    @contributors = @github_repository.github_contributions.order('count DESC').limit(20).includes(:github_user)
    @projects = @github_repository.projects
    @color = @github_repository.color
  end

  def contributors
    load_repo
    @contributors = @github_repository.github_contributions.order('count DESC').includes(:github_user).paginate(page: params[:page])
  end

  def load_repo
    full_name = [params[:owner], params[:name]].join('/')
    @github_repository = GithubRepository.where(full_name: full_name).first
    @github_repository = GithubRepository.where('lower(full_name) = ?', full_name.downcase).first if @github_repository.nil?
    raise ActiveRecord::RecordNotFound if @github_repository.nil?
    raise ActiveRecord::RecordNotFound unless authorized?
{'fraction_non_alphanumeric': 0.15339366515837105, 'fraction_numerical': 0.005429864253393665, 'mean_word_length': 5.454014598540146, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4036248', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1386, 'n_words': 221}