<commit_before>namespace :router do
  task :router_environment => :environment do
    require 'plek'
    require 'gds_api/router'

    @router_api = GdsApi::Router.new(Plek.current.find('router-api'))
  end

  task :register => [:register_backend, :register_browse]

  task :register_backend => :router_environment do
    @router_api.add_backend('collections', Plek.current.find('collections', :force_http => true) + "/")
  end

  task :register_browse => [:unregister_browse_redirects, :router_environment] do
    routes = [
      %w(/browse prefix),
      %w(/browse.json exact),
    ]

    routes.each do |path, type|
      @router_api.add_route(path, type, 'collections')<commit_msg>Register redirects for browse pages at root on deploy<commit_after>namespace :router do
  task :router_environment => :environment do
    require 'plek'
    require 'gds_api/router'

    @router_api = GdsApi::Router.new(Plek.current.find('router-api'))
  end

  task :register => [:register_backend, :register_browse]

  task :register_backend => :router_environment do
    @router_api.add_backend('collections', Plek.current.find('collections', :force_http => true) + "/")
  end

  task :register_browse => [:unregister_browse_redirects, :register_browse_redirects, :router_environment] do
    routes = [
      %w(/browse prefix),
      %w(/browse.json exact),
    ]

    routes.each do |path, type|
      @router_api.add_route(path, type, 'collections')
    end
    @router_api.commit_routes
  end

  task :register_browse_redirects => :router_environment do
    routes = [
      %w(/visas-immigration /browse/visas-immigration),
      %w(/business /browse/business),
    ]

    routes.each do |path, destination|
      @router_api.add_redirect_route(path, 'prefix', destination)
{'fraction_non_alphanumeric': 0.12839366515837103, 'fraction_numerical': 0.0, 'mean_word_length': 4.054285714285714, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '2932914', 'n_tokens_mistral': 594, 'n_tokens_neox': 575, 'n_words': 115}