<commit_before>class GithubRepositoriesController < ApplicationController
  def index
    postfix = [current_language, current_license, current_keywords].any?(&:present?) ? 'Repos' : 'Repositories'
    @title = [current_language, current_license, current_keywords, postfix].compact.join(' ')

    @popular = repo_search('stargazers_count')
    @forked = repo_search('forks_count')
    @created = repo_search('created_at')
    @updated = repo_search('pushed_at')

    facets = GithubRepository.facets(filters: {language: current_language, license: current_license, keywords: current_keywords}, :facet_limit => 20)

    @languages = facets[:language][:terms]
    @licenses = facets[:license][:terms].reject{ |t| t.term.downcase == 'other' }
    @keywords = facets[:keywords][:terms]
  end

  def search
    @query = params[:q]
    @search = GithubRepository.search(params[:q], filters: {
      license: current_licenses,
      language: current_language,
      keywords: current_keywords,
      platforms: current_platforms
    }, sort: format_sort, order: format_order).paginate(page: page_number, per_page: per_page_number)
    @suggestion = @search.response.suggest.did_you_mean.first
    @github_repositories = @search.records
    @title = page_title
    respond_to do |format|
      format.html
      format.atom
    end
  end

  def languages
    @languages = GithubRepository.search('', :facet_limit => 150).response.facets[:language][:terms]
  end

  def hacker_news
    @language = Languages::Language[params[:language]] if params[:language].present?

    orginal_scope = GithubRepository.trending
    scope = @language.present? ? orginal_scope.where('lower(language) = ?', @language.name.downcase) : orginal_scope
    @repos = scope.hacker_news.paginate(page: page_number)

    @languages = orginal_scope.group('lower(language)').count.reject{|k,v| k.blank? }.sort_by{|k,v| v }.reverse.first(40)
  end

  def new
    @language = Languages::Language[params[:language]] if params[:language].present?

    orginal_scope = GithubRepository.interesting
    scope = @language.present? ? orginal_scope.where('lower(language) = ?', @language.name.downcase) : orginal_scope
    @repos = scope.recently_created.order('created_at DESC').paginate(page: page_number)

    @languages = orginal_scope.recently_created.group('lower(language)').count.reject{|k,v| k.blank? }.sort_by{|k,v| v }.reverse.first(40)
  end

  def show
    load_repo
    @contributors = @github_repository.contributors.order('count DESC').visible.limit(20)
    @projects = @github_repository.projects.limit(20).includes(:versions)
    @color = @github_repository.color
    @forks = @github_repository.forked_repositories.interesting.limit(5)
    @manifests = @github_repository.manifests.latest.limit(10).includes(repository_dependencies: {project: :versions})
  end
<commit_msg>Fix unused block var warning<commit_after>class GithubRepositoriesController < ApplicationController
  def index
    postfix = [current_language, current_license, current_keywords].any?(&:present?) ? 'Repos' : 'Repositories'
    @title = [current_language, current_license, current_keywords, postfix].compact.join(' ')

    @popular = repo_search('stargazers_count')
    @forked = repo_search('forks_count')
    @created = repo_search('created_at')
    @updated = repo_search('pushed_at')

    facets = GithubRepository.facets(filters: {language: current_language, license: current_license, keywords: current_keywords}, :facet_limit => 20)

    @languages = facets[:language][:terms]
    @licenses = facets[:license][:terms].reject{ |t| t.term.downcase == 'other' }
    @keywords = facets[:keywords][:terms]
  end

  def search
    @query = params[:q]
    @search = GithubRepository.search(params[:q], filters: {
      license: current_licenses,
      language: current_language,
      keywords: current_keywords,
      platforms: current_platforms
    }, sort: format_sort, order: format_order).paginate(page: page_number, per_page: per_page_number)
    @suggestion = @search.response.suggest.did_you_mean.first
    @github_repositories = @search.records
    @title = page_title
    respond_to do |format|
      format.html
      format.atom
    end
  end

  def languages
    @languages = GithubRepository.search('', :facet_limit => 150).response.facets[:language][:terms]
  end

  def hacker_news
    @language = Languages::Language[params[:language]] if params[:language].present?

    orginal_scope = GithubRepository.trending
    scope = @language.present? ? orginal_scope.where('lower(language) = ?', @language.name.downcase) : orginal_scope
    @repos = scope.hacker_news.paginate(page: page_number)

    @languages = orginal_scope.group('lower(language)').count.reject{|k,_v| k.blank? }.sort_by{|_k,v| v }.reverse.first(40)
  end

  def new
    @language = Languages::Language[params[:language]] if params[:language].present?

    orginal_scope = GithubRepository.interesting
    scope = @language.present? ? orginal_scope.where('lower(language) = ?', @language.name.downcase) : orginal_scope
    @repos = scope.recently_created.order('created_at DESC').paginate(page: page_number)

    @languages = orginal_scope.recently_created.group('lower(language)').count.reject{|k,_v| k.blank? }.sort_by{|_k,v| v }.reverse.first(40)
  end

  def show
    load_repo
    @contributors = @github_repository.contributors.order('count DESC').visible.limit(20)
    @projects = @github_repository.projects.limit(20).includes(:versions)
    @color = @github_repository.color
    @forks = @github_repository.forked_repositories.interesting.limit(5)
    @manifests = @github_repository.manifests.latest.limit(10).includes(repository_dependencies: {project: :versions})
  end

{'fraction_non_alphanumeric': 0.13237611626685344, 'fraction_numerical': 0.005603221852565225, 'mean_word_length': 4.956204379562044, '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': '4548370', 'n_tokens_mistral': 1877, 'n_tokens_neox': 1754, 'n_words': 304}