<commit_before>class ItinerariesController < ApplicationController
  def new
  end

  def create
    if params["search"]
      yelp = YelpApi.new
      @activities = []
      @search = params["search"]["ids"]
      @user_address = params["address"]

      if @user_address == ""
        yelp.set_location(params[:latitude],params[:longitude])
      else
        yelp.set_address(params["address"])
      end

      @search.each do |k,v|
        yelp.set_params(v["term"], v["tag"], params["sort"])
        if @user_address == ""
          yelp.search
          @activities << yelp.results
        else
          yelp.search_by_address
          @activities << yelp.results
        end
      end

    elsif params["activity_ids"]
      if current_user.nil?
        session[:itinerary] = params
        # redirect_to new_user_registration_path
      else
        @itinerary = Itinerary.create(user_id:current_user.id)
        @itinerary.add_activities(params["activity_ids"])
        respond_to do |format|
          format.js
        end
      end
    end
    respond_to do |format|
      format.html
    end
  end

  def show
    @itinerary = Itinerary.find(params[:id])
    @activities = @itinerary.activities
  end
end<commit_msg>fix broken save button, but still need work on session<commit_after>class ItinerariesController < ApplicationController
  def new
  end

  def create
    if params["search"]
      yelp = YelpApi.new
      @activities = []
      @search = params["search"]["ids"]
      @user_address = params["address"]

      if @user_address == ""
        yelp.set_location(params[:latitude],params[:longitude])
      else
        yelp.set_address(params["address"])
      end

      @search.each do |k,v|
        yelp.set_params(v["term"], v["tag"], params["sort"])
        if @user_address == ""
          yelp.search
          @activities << yelp.results
        else
          yelp.search_by_address
          @activities << yelp.results
        end
      end

    elsif params["activity_ids"]
      if current_user.nil?
        session[:itinerary] = params
        # redirect_to new_user_registration_path
      else
        @itinerary = Itinerary.create(user_id:current_user.id)
        @itinerary.add_activities(params["activity_ids"])
      end
    end
    respond_to do |format|
      format.js
      format.html
    end
  end

  def show
    @itinerary = Itinerary.find(params[:id])
    @activities = @itinerary.activities
  end
end
{'fraction_non_alphanumeric': 0.10781122864117168, 'fraction_numerical': 0.0, 'mean_word_length': 2.3410326086956523, 'pattern_counts': {'":': 0, '<': 13, '<?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': '239086', 'n_tokens_mistral': 779, 'n_tokens_neox': 752, 'n_words': 150}