<commit_before>class YelpsController < ApplicationController
  require 'yelp'

  def index

  end

  def add
    @location = params[:location]

    @events_call = Yelp.client.search(@location, { term: 'events', limit: 16 }).businesses
    @restaurants_call = Yelp.client.search(@location, { term: 'restaurants', limit: 16 }).businesses
    @monuments_call = Yelp.client.search(@location, { term: 'monuments', limit: 16 }).businesses

    if params[:event] || params[:restaurant]
      yelp_event = @events_call.select { |business| business.name == params[:event] }[0]
      yelp_restaurant = @restaurants_call.select { |restaurant| restaurant.name == params[:restaurant] }[0]
      yelp_monument = @monuments_call.select { |monument| monument.name == params[:monument] }[0]
      p "O*" * 200
      if request.xhr?
        if yelp_event
          p "-*-*" * 200
          session["events"] << yelp_event.name
          render partial: 'guides/add_event', layout: false, locals: {event: yelp_event}
        elsif yelp_restaurant
          session["events"] << yelp_restaurant.name
          render partial: 'guides/add_restaurant', layout: false, locals: {restaurant: yelp_restaurant}
        end
      end
    end
  end

  def remove
    @location = params[:location]

    session["events"] ||= (session["events"] = [])
    @events_call = Yelp.client.search(@location, { term: 'events', limit: 16 }).businesses
    @restaurants_call = Yelp.client.search(@location, { term: 'restaurants', limit: 16 }).businesses

    if params[:event] || params[:restaurant]
      yelp_event = @events_call.select { |business| business.name == params[:event]}[0]
      session["events"].delete(params[:event])
      session["events"].delete(params[:restaurant])
      session["events"].delete(params[:monument])
      if request.xhr?
        if session["events"].include?(params[:event])
          render partial: 'guides/remove_event', layout: false, locals: {event: yelp_event}
        elsif session["events"].include?(params[:restaurant])
          render partial: 'guides/remove_restaurant', layout: false, locals: {event: yelp_restaurant}
        end
      # else
      #   session["events"].delete(params[:event])
      end
    end
  end

  def create<commit_msg>take out unnecessary code and comments from the yelps_controller<commit_after>class YelpsController < ApplicationController
  require 'yelp'

  def index

  end

  def add
    @location = params[:location]

    @events_call = Yelp.client.search(@location, { term: 'events', limit: 16 }).businesses
    @restaurants_call = Yelp.client.search(@location, { term: 'restaurants', limit: 16 }).businesses
    @monuments_call = Yelp.client.search(@location, { term: 'monuments', limit: 16 }).businesses

    if params[:event] || params[:restaurant]
      yelp_event = @events_call.select { |business| business.name == params[:event] }[0]
      yelp_restaurant = @restaurants_call.select { |restaurant| restaurant.name == params[:restaurant] }[0]
      yelp_monument = @monuments_call.select { |monument| monument.name == params[:monument] }[0]
      p "O*" * 200
      if request.xhr?
        if yelp_event
          p "-*-*" * 200
          session["events"] << yelp_event.name
          render partial: 'guides/add_event', layout: false, locals: {event: yelp_event}
        elsif yelp_restaurant
          session["events"] << yelp_restaurant.name
          render partial: 'guides/add_restaurant', layout: false, locals: {restaurant: yelp_restaurant}
        end
      end
    end
  end

  def remove
    @location = params[:location]

    session["events"] ||= (session["events"] = [])
    @events_call = Yelp.client.search(@location, { term: 'events', limit: 16 }).businesses
    @restaurants_call = Yelp.client.search(@location, { term: 'restaurants', limit: 16 }).businesses

    if params[:event] || params[:restaurant] || params[:monument]
      yelp_event = @events_call.select { |business| business.name == params[:event]}[0]
      session["events"].delete(params[:event])
      session["events"].delete(params[:restaurant])
      session["events"].delete(params[:monument])
      if request.xhr?
        if session["events"].include?(params[:event])
          render partial: 'guides/remove_event', layout: false, locals: {event: yelp_event}
        elsif session["events"].include?(params[:restaurant])
          render partial: 'guides/remove_restaurant', layout: false, locals: {event: yelp_restaurant}
        end
      end
    end
  end

  def create
{'fraction_non_alphanumeric': 0.14250886524822695, 'fraction_numerical': 0.008865248226950355, 'mean_word_length': 3.531124497991968, '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': '5697394', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1348, 'n_words': 306}