<commit_before>module NanoApi
  class SearchesController < NanoApi::ApplicationController
    include NanoApi::Extensions::Markerable
    include NanoApi::Extensions::UserLocation

    before_filter :handle_marker, :only => :new

    def new
      @search = Search.new(search_params)
    end

    def show
      @search = Search.find(params[:id])
      render :new
    end

    def create
      @search = Search.new(params[:search])
      cookies[:ls] = @search.attributes_for_cookies.to_json

      search_result = @search.search(request.host)

      if search_result.present?
        forward_json(*search_result)
      else
        render json: {}, status: :internal_server_error
      end
    end

  private

    def search_params
      cookie_defaults = JSON.parse(cookies[:ls].presence) rescue {}
      search_params = params[:search].is_a?(Hash) ? params[:search] : params
      user_location_attributes.merge(cookie_defaults).merge(search_params)
    end

  end
end
<commit_msg>Правки контроллера формы для обработки nano_mobile.<commit_after>module NanoApi
  class SearchesController < NanoApi::ApplicationController
    include NanoApi::Extensions::Markerable
    include NanoApi::Extensions::UserLocation

    before_filter :handle_marker, :only => :new

    def new
      @search = Search.new(search_params)
    end

    def show
      @search = Search.find(params[:id])
      render :new
    end

    def create
      @search = Search.new(params[:search].is_a?(Hash) ? params[:search] : params)
      cookies[:ls] = @search.attributes_for_cookies.to_json

      search_result = @search.search(request.host)

      if search_result.present?
        forward_json(*search_result)
      else
        render json: {}, status: :internal_server_error
      end
    end

  private

    def search_params
      cookie_defaults = JSON.parse(cookies[:ls].presence) rescue {}
      search_params = params[:search].is_a?(Hash) ? params[:search] : params
      user_location_attributes.merge(cookie_defaults).merge(search_params)
    end

  end
end

{'fraction_non_alphanumeric': 0.09770395701025891, 'fraction_numerical': 0.0, 'mean_word_length': 3.3389830508474576, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5036548', 'n_tokens_mistral': 615, 'n_tokens_neox': 595, 'n_words': 121}