<commit_before># frozen_string_literal: true
class LocationController < ApplicationController
  include StringUtils

  # GET /es/location/change
  def ask
  end

  # POST /es/location/change
  # GET /es/location/change2?location=:location
  def list
    return unless params[:location]

    if similar_locations && similar_locations.count == 1
      save_location similar_locations[0].woeid
    else
      @locations = similar_locations
    end
  end

  # POST /es/location/change2
  def change
    if positive_integer?(params[:location])
      save_location params[:location]
    else
      if similar_locations & similar_locations.count == 1
        save_location similar_locations[0].woeid
      else
        redirect_to location_ask_path, alert: 'Hubo un error con el cambio de su ubicación. Inténtelo de nuevo.'
      end
    end
  end

  private
<commit_msg>Extract another method in `location_controller`<commit_after># frozen_string_literal: true
class LocationController < ApplicationController
  include StringUtils

  # GET /es/location/change
  def ask
  end

  # POST /es/location/change
  # GET /es/location/change2?location=:location
  def list
    return unless params[:location]

    if unique_location
      save_location unique_location.woeid
    else
      @locations = similar_locations
    end
  end

  # POST /es/location/change2
  def change
    if positive_integer?(params[:location])
      save_location params[:location]
    elsif unique_location
      save_location unique_location.woeid
    else
      redirect_to location_ask_path, alert: 'Hubo un error con el cambio de su ubicación. Inténtelo de nuevo.'
    end
  end

  private

  def unique_location
    return unless similar_locations && similar_locations.count == 1

    similar_locations[0]
  end

{'fraction_non_alphanumeric': 0.06502242152466367, 'fraction_numerical': 0.005605381165919282, 'mean_word_length': 3.343065693430657, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2217935', 'n_tokens_mistral': 536, 'n_tokens_neox': 510, 'n_words': 143}