<commit_before>class User::LocationsController < ApplicationController
  def index
  end

  def create
    @location = current_user.build_location permitted_params

    if @location.save
      set_flash_message :success
      redirect_to action: :index
    else
      @start_location = Geo::NOWHERE_IN_PARTICULAR
      render :new
    end
  end

  def new
    # Get the start location before creating a new blank one
    @start_location = current_user.start_location
    @location = current_user.location || current_user.build_location
  end

  def update
    @location = current_user.location

    if @location.update permitted_params
      set_flash_message :success
      redirect_to action: :index
    else
      render :edit
    end
  end

  def geometry
    @location = current_user.location
    respond_to do |format|
      format.json { render json: RGeo::GeoJSON.encode(@location.loc_feature(thumbnail: view_context.image_path('map-icons/m-misc.png'))) }
    end
  end

  def combined_geometry
    multi = current_user.buffered_location
    respond_to do |format|
      format.json { render json: RGeo::GeoJSON.encode(multi) }
    end
  end

  protected

  def permitted_params
    params.require(:user_location).permit :category_id, :loc_json
  end
end
<commit_msg>Always update existing user location<commit_after>class User::LocationsController < ApplicationController
  def index
  end

  def create
    @location = current_user.location || current_user.build_location

    if @location.update permitted_params
      set_flash_message :success
      redirect_to action: :index
    else
      @start_location = Geo::NOWHERE_IN_PARTICULAR
      render :new
    end
  end

  def new
    # Get the start location before creating a new blank one
    @start_location = current_user.start_location
    @location = current_user.location || current_user.build_location
  end

  def update
    @location = current_user.location

    if @location.update permitted_params
      set_flash_message :success
      redirect_to action: :index
    else
      render :edit
    end
  end

  def geometry
    @location = current_user.location
    respond_to do |format|
      format.json { render json: RGeo::GeoJSON.encode(@location.loc_feature(thumbnail: view_context.image_path('map-icons/m-misc.png'))) }
    end
  end

  def combined_geometry
    multi = current_user.buffered_location
    respond_to do |format|
      format.json { render json: RGeo::GeoJSON.encode(multi) }
    end
  end

  protected

  def permitted_params
    params.require(:user_location).permit :category_id, :loc_json
  end
end

{'fraction_non_alphanumeric': 0.06807692307692308, 'fraction_numerical': 0.0, 'mean_word_length': 3.349498327759197, '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': '1074470', 'n_tokens_mistral': 786, 'n_tokens_neox': 760, 'n_words': 195}