<commit_before>Rails.application.routes.draw do
  require 'sidekiq/web'
  Sidekiq::Web.use Rack::Auth::Basic do |username, password|
    username == ENV["SIDEKIQ_USERNAME"] && password == ENV["SIDEKIQ_PASSWORD"]
  end if Rails.env.production?
  mount Sidekiq::Web => '/sidekiq'

  mount PgHero::Engine, at: "pghero"

  get '/home', to: 'dashboard#home'

  namespace :api do
    post '/check', to: 'status#check'

    get '/', to: 'docs#index'
    get '/search', to: 'search#index'
    get '/bower-search', to: 'bower_search#index'
    get '/searchcode', to: 'projects#searchcode'

    get '/platforms', to: 'platforms#index'

    get '/subscriptions', to: 'subscriptions#index'
    get '/subscriptions/:platform/:name', to: 'subscriptions#show'
    post '/subscriptions/:platform/:name', to: 'subscriptions#create'
    put '/subscriptions/:platform/:name', to: 'subscriptions#update'
    delete '/subscriptions/:platform/:name', to: 'subscriptions#destroy'

    # legacy due to typo
    get '/subscription/:platform/:name', to: 'subscriptions#show'
    post '/subscription/:platform/:name', to: 'subscriptions#create'
    put '/subscription/:platform/:name', to: 'subscriptions#update'
    delete '/subscription/:platform/:name', to: 'subscriptions#destroy'

    scope constraints: {host_type: /(github|gitlab|bitbucket)/i}, defaults: { host_type: 'github' } do
      get '/:host_type/issues/help-wanted', to: 'issues#help_wanted'
      get '/:host_type/issues/first-pull-request', to: 'issues#first_pull_request'

      get '/:host_type/search', to: 'repositories#search'

      get '/:host_type/:login/project-contributions', to: 'repository_users#project_contributions'
      get '/:host_type/:login/repository-contributions', to: 'repository_users#repository_contributions'
      get '/:host_type/:login/repositories', to: 'repository_users#repositories'
      get '/:host_type/:login/projects', to: 'repository_users#projects'

      get '/:host_type/:owner/:name/dependencies', to: 'repositories#dependencies', constraints: { :name => /[^\/]+/ }
      get '/:host_type/:owner/:name/projects', to: 'repositories#projects', constraints: { :name => /[^\/]+/ }
      get '/:host_type/:owner/:name', to: 'repositories#show', constraints: { :name => /[^\/]+/ }

      get '/:host_type/:login', to: 'repository_users#show'
    end

    PLATFORM_CONSTRAINT = /[\w\-]+/
    PROJECT_CONSTRAINT = /[^\/]+/
    VERSION_CONSTRAINT = /[\w\.\-]+/

    get '/:platform/:name/sourcerank', to: 'projects#sourcerank', constraints: { :platform => PLATFORM_CONSTRAINT, :name => PROJECT_CONSTRAINT }
    get '/:platform/:name/contributors', to: 'projects#contributors', constraints: { :platform => PLATFORM_CONSTRAINT, :name => PROJECT_CONSTRAINT }
    get '/:platform/:name/:version/tree', to: 'tree#show', constraints: { :platform => /[\w\-]+/, :name => PROJECT_CONSTRAINT, :version => VERSION_CONSTRAINT }, as: :version_tree
    get '/:platform/:name/:version/dependencies', to: 'projects#dependencies', constraints: { :platform => PLATFORM_CONSTRAINT, :name => PROJECT_CONSTRAINT, :version => VERSION_CONSTRAINT }
    get '/:platform/:name/dependent_repositories', to: 'projects#dependent_repositories', constraints: { :platform => PLATFORM_CONSTRAINT, :name => PROJECT_CONSTRAINT }
    get '/:platform/:name/dependents', to: 'projects#dependents', constraints: { :platform => PLATFORM_CONSTRAINT, :name => PROJECT_CONSTRAINT }
    get '/:platform/:name/tree', to: 'tree#show', constraints: { :platform => PLATFORM_CONSTRAINT, :name => PROJECT_CONSTRAINT }, as: :tree
    get '/:platform/:name', to: 'projects#show', constraints: { :platform => PLATFORM_CONSTRAINT, :name => PROJECT_CONSTRAINT }
  end

  namespace :admin do
    resources :projects do
      collection do
        get 'deprecated'
        get 'unmaintained'
      end
    end
    resources :project_suggestions
    resources :repositories do
      member do
        put 'deprecate'
        put 'unmaintain'
      end
      collection do
        get 'deprecated'
        get 'unmaintained'
      end
    end
    get '/:host_type/:login', to: 'repository_organisations#show'
    get '/stats', to: 'stats#index', as: :stats
    get '/stats/repositories', to: 'stats#repositories', as: :repositories_stats
    get '/graphs', to: 'stats#graphs', as: :graphs
    get '/', to: 'stats#overview', as: :overview
  end

  get '/trending', to: 'projects#trending', as: :trending_projects
  get '/explore', to: 'explore#index'
  get '/collections', to: 'collections#index', as: :collections
  get '/explore/:language-:keyword-libraries', to: 'collections#show', as: :collection

  get '/recommendations', to: 'recommendations#index', as: :recommendations

  get '/repositories', to: 'dashboard#index', as: :repositories
  get '/dashboard', to: redirect("/repositories")
  get '/muted', to: 'dashboard#muted', as: :muted
  post '/repositories/sync', to: 'dashboard#sync', as: :sync
  post '/watch/:repository_id', to: 'dashboard#watch', as: :watch
  post '/unwatch/:repository_id', to: 'dashboard#unwatch', as: :unwatch

  resource :account do
    member do
      get 'delete'
      put 'disable_emails'<commit_msg>Reorder admin routes<commit_after>Rails.application.routes.draw do
  require 'sidekiq/web'
  Sidekiq::Web.use Rack::Auth::Basic do |username, password|
    username == ENV["SIDEKIQ_USERNAME"] && password == ENV["SIDEKIQ_PASSWORD"]
  end if Rails.env.production?
  mount Sidekiq::Web => '/sidekiq'

  mount PgHero::Engine, at: "pghero"

  get '/home', to: 'dashboard#home'

  namespace :api do
    post '/check', to: 'status#check'

    get '/', to: 'docs#index'
    get '/search', to: 'search#index'
    get '/bower-search', to: 'bower_search#index'
    get '/searchcode', to: 'projects#searchcode'

    get '/platforms', to: 'platforms#index'

    get '/subscriptions', to: 'subscriptions#index'
    get '/subscriptions/:platform/:name', to: 'subscriptions#show'
    post '/subscriptions/:platform/:name', to: 'subscriptions#create'
    put '/subscriptions/:platform/:name', to: 'subscriptions#update'
    delete '/subscriptions/:platform/:name', to: 'subscriptions#destroy'

    # legacy due to typo
    get '/subscription/:platform/:name', to: 'subscriptions#show'
    post '/subscription/:platform/:name', to: 'subscriptions#create'
    put '/subscription/:platform/:name', to: 'subscriptions#update'
    delete '/subscription/:platform/:name', to: 'subscriptions#destroy'

    scope constraints: {host_type: /(github|gitlab|bitbucket)/i}, defaults: { host_type: 'github' } do
      get '/:host_type/issues/help-wanted', to: 'issues#help_wanted'
      get '/:host_type/issues/first-pull-request', to: 'issues#first_pull_request'

      get '/:host_type/search', to: 'repositories#search'

      get '/:host_type/:login/project-contributions', to: 'repository_users#project_contributions'
      get '/:host_type/:login/repository-contributions', to: 'repository_users#repository_contributions'
      get '/:host_type/:login/repositories', to: 'repository_users#repositories'
      get '/:host_type/:login/projects', to: 'repository_users#projects'

      get '/:host_type/:owner/:name/dependencies', to: 'repositories#dependencies', constraints: { :name => /[^\/]+/ }
      get '/:host_type/:owner/:name/projects', to: 'repositories#projects', constraints: { :name => /[^\/]+/ }
      get '/:host_type/:owner/:name', to: 'repositories#show', constraints: { :name => /[^\/]+/ }

      get '/:host_type/:login', to: 'repository_users#show'
    end

    PLATFORM_CONSTRAINT = /[\w\-]+/
    PROJECT_CONSTRAINT = /[^\/]+/
    VERSION_CONSTRAINT = /[\w\.\-]+/

    get '/:platform/:name/sourcerank', to: 'projects#sourcerank', constraints: { :platform => PLATFORM_CONSTRAINT, :name => PROJECT_CONSTRAINT }
    get '/:platform/:name/contributors', to: 'projects#contributors', constraints: { :platform => PLATFORM_CONSTRAINT, :name => PROJECT_CONSTRAINT }
    get '/:platform/:name/:version/tree', to: 'tree#show', constraints: { :platform => /[\w\-]+/, :name => PROJECT_CONSTRAINT, :version => VERSION_CONSTRAINT }, as: :version_tree
    get '/:platform/:name/:version/dependencies', to: 'projects#dependencies', constraints: { :platform => PLATFORM_CONSTRAINT, :name => PROJECT_CONSTRAINT, :version => VERSION_CONSTRAINT }
    get '/:platform/:name/dependent_repositories', to: 'projects#dependent_repositories', constraints: { :platform => PLATFORM_CONSTRAINT, :name => PROJECT_CONSTRAINT }
    get '/:platform/:name/dependents', to: 'projects#dependents', constraints: { :platform => PLATFORM_CONSTRAINT, :name => PROJECT_CONSTRAINT }
    get '/:platform/:name/tree', to: 'tree#show', constraints: { :platform => PLATFORM_CONSTRAINT, :name => PROJECT_CONSTRAINT }, as: :tree
    get '/:platform/:name', to: 'projects#show', constraints: { :platform => PLATFORM_CONSTRAINT, :name => PROJECT_CONSTRAINT }
  end

  namespace :admin do
    resources :projects do
      collection do
        get 'deprecated'
        get 'unmaintained'
      end
    end
    resources :project_suggestions
    resources :repositories do
      member do
        put 'deprecate'
        put 'unmaintain'
      end
      collection do
        get 'deprecated'
        get 'unmaintained'
      end
    end

    get '/stats', to: 'stats#index', as: :stats
    get '/stats/repositories', to: 'stats#repositories', as: :repositories_stats
    get '/graphs', to: 'stats#graphs', as: :graphs
    get '/:host_type/:login', to: 'repository_organisations#show'
    get '/', to: 'stats#overview', as: :overview
  end

  get '/trending', to: 'projects#trending', as: :trending_projects
  get '/explore', to: 'explore#index'
  get '/collections', to: 'collections#index', as: :collections
  get '/explore/:language-:keyword-libraries', to: 'collections#show', as: :collection

  get '/recommendations', to: 'recommendations#index', as: :recommendations

  get '/repositories', to: 'dashboard#index', as: :repositories
  get '/dashboard', to: redirect("/repositories")
  get '/muted', to: 'dashboard#muted', as: :muted
  post '/repositories/sync', to: 'dashboard#sync', as: :sync
  post '/watch/:repository_id', to: 'dashboard#watch', as: :watch
  post '/unwatch/:repository_id', to: 'dashboard#unwatch', as: :unwatch

  resource :account do
    member do
      get 'delete'
      put 'disable_emails'
{'fraction_non_alphanumeric': 0.16534212056600117, 'fraction_numerical': 0.0, 'mean_word_length': 4.243394308943089, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 47, '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': '6490713', 'n_tokens_mistral': 3395, 'n_tokens_neox': 3337, 'n_words': 743}