<commit_before>class ProjectsController < ApplicationController
  def index
    facets = Project.facets(:facet_limit => 30)

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

  def bus_factor
    if params[:language].present?
      @language = GithubRepository.where('lower(language) = ?', params[:language].downcase).first.try(:language)
      raise ActiveRecord::RecordNotFound if @language.nil?
      scope = Project.language(@language)
    else
      scope = Project
    end

    @languages = Project.bus_factor.group('github_repositories.language').order('github_repositories.language').pluck('github_repositories.language').compact

    @projects = scope.bus_factor.order('projects.dependents_count DESC, github_repositories.github_contributions_count ASC').paginate(page: params[:page])
  end

  def show
    find_project
    if incorrect_case?
      if params[:number].present?
        return redirect_to(version_path(@project.to_param.merge(number: params[:number])), :status => :moved_permanently)
      else
        return redirect_to(project_path(@project.to_param), :status => :moved_permanently)
      end
    end
    @version_count = @project.versions.count
    @github_repository = @project.github_repository
    if @version_count.zero?
      @versions = []
      if @github_repository.present?
        @github_tags = @github_repository.github_tags.published.order('published_at DESC').limit(10).to_a.sort
        if params[:number].present?
          @version = @github_repository.github_tags.published.find_by_name(params[:number])
          raise ActiveRecord::RecordNotFound if @version.nil?
        end
      else
        @github_tags = []
      end
      if @versions.empty? && @github_tags.empty?
        raise ActiveRecord::RecordNotFound if params[:number].present?
      end
    else
      @versions = @project.versions.order('published_at DESC').limit(10).to_a.sort<commit_msg>Swap ordering to prompt lowest contributor counts<commit_after>class ProjectsController < ApplicationController
  def index
    facets = Project.facets(:facet_limit => 30)

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

  def bus_factor
    if params[:language].present?
      @language = GithubRepository.where('lower(language) = ?', params[:language].downcase).first.try(:language)
      raise ActiveRecord::RecordNotFound if @language.nil?
      scope = Project.language(@language)
    else
      scope = Project
    end

    @languages = Project.bus_factor.group('github_repositories.language').order('github_repositories.language').pluck('github_repositories.language').compact

    @projects = scope.bus_factor.order('github_repositories.github_contributions_count ASC, projects.dependents_count DESC').paginate(page: params[:page])
  end

  def show
    find_project
    if incorrect_case?
      if params[:number].present?
        return redirect_to(version_path(@project.to_param.merge(number: params[:number])), :status => :moved_permanently)
      else
        return redirect_to(project_path(@project.to_param), :status => :moved_permanently)
      end
    end
    @version_count = @project.versions.count
    @github_repository = @project.github_repository
    if @version_count.zero?
      @versions = []
      if @github_repository.present?
        @github_tags = @github_repository.github_tags.published.order('published_at DESC').limit(10).to_a.sort
        if params[:number].present?
          @version = @github_repository.github_tags.published.find_by_name(params[:number])
          raise ActiveRecord::RecordNotFound if @version.nil?
        end
      else
        @github_tags = []
      end
      if @versions.empty? && @github_tags.empty?
        raise ActiveRecord::RecordNotFound if params[:number].present?
      end
    else
      @versions = @project.versions.order('published_at DESC').limit(10).to_a.sort
{'fraction_non_alphanumeric': 0.121414913957935, 'fraction_numerical': 0.0028680688336520078, 'mean_word_length': 3.906213364595545, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3089957', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1189, 'n_words': 207}