<commit_before>require 'json'

post '/wines' do


  search_query2 = nil
  if params[:type] == 'red' || params[:type] == 'white'
    search_query2 = "&t=wine&color=" + params[:type]
  elsif params[:type] == 'sparkling'
    search_query2 = "&t=" + params[:type]
  end

  if params[:varietal]
    search_query1 = "&q=" + params[:varietal]
  else
    search_query1 = "&q=wine"
  end

  # Remove spaces from 2 word wine types
  search_query1 = search_query1.gsub(/\s/, '&20')
  search_query2 = search_query2.gsub(/\s/, '&20')

  response = RestClient.get "http://api.snooth.com/wines/?akey=" + ENV['API_KEY'] +"&ip=172.16.58.3&q=" + search_query1 + '&n=2' + search_query2

  parsed_data = JSON.parse(response)
  # puts parsed_data

  wines = parsed_data["wines"]
  # puts wines
  #
  wine_codes = []
  wines.each do |wine|
    wine_codes << wine["code"]
  end

  @recipes = []
  wine_codes.each do |code|
      response = RestClient.get "http://api.snooth.com/wine/?akey=" + ENV['API_KEY'] + "&ip=172.16.58.3&food=1&id=" + code
      parsed_data = JSON.parse(response)
      hashed_data = parsed_data["wines"][0]["recipes"]
      hashed_data.each do |recipe_hash|
        @recipes << recipe_hash
      end
  end


  puts @recipes.uniq!
  puts @recipes.count

  return erb :'_recipe_card', layout: false


  # return recipes.to_json



end
<commit_msg>Made changes to app<commit_after>require 'json'

post '/wines' do


  search_query2 = nil
  if params[:type] == 'red' || params[:type] == 'white'
    search_query2 = "&t=wine&color=" + params[:type]
  elsif params[:type] == 'sparkling'
    search_query2 = "&t=" + params[:type]
  end

  if params[:varietal]
    search_query1 = "&q=" + params[:varietal]
  else
    search_query1 = "&q=wine"
  end

  # Remove spaces from 2 word wine types
  search_query1 = search_query1.gsub(/\s/, '&20')
  search_query2 = search_query2.gsub(/\s/, '&20')

  response = RestClient.get "http://api.snooth.com/wines/?akey=" + ENV['API_KEY'] +"&ip=172.16.58.3&q=" + search_query1 + '&n=2' + search_query2

  parsed_data = JSON.parse(response)
  # puts parsed_data

  wines = parsed_data["wines"]
  # puts wines
  #
  wine_codes = []
  wines.each do |wine|
    wine_codes << wine["code"]
  end

  @recipes = []
  wine_codes.each do |code|
      response = RestClient.get "http://api.snooth.com/wine/?akey=" + ENV['API_KEY'] + "&ip=172.16.58.3&food=1&id=" + code
      parsed_data = JSON.parse(response)
      hashed_data = parsed_data["wines"][0]["recipes"]
      hashed_data.each do |recipe_hash|
        @recipes << recipe_hash
      end
  end


  puts @recipes.uniq!
  puts @recipes.count

  return erb :'_recipe_card', layout: false


  # return recipes.to_json



end

{'fraction_non_alphanumeric': 0.16456634544106746, 'fraction_numerical': 0.025945144551519646, 'mean_word_length': 3.4391447368421053, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '6504950', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1035, 'n_words': 203}