<commit_before>hotels      = Spree::Product.all
rooms       = Spree::OptionValue.where(:option_type_id=>3)
meal_plans  = Spree::OptionValue.where(:option_type_id=>4)
adults      = [1..4]
children    = [0..3]
seasons     = 2 #4
rates       = []

hotels.each do |h|
  rooms.to_a.each_with_index do |r, r_index|
    meal_plans.to_a.each_with_index do |mp, mp_index|
      for s in 1..seasons
        rates << {
          product: h, 
          room_id: r.id, 
          start_date: "2014-01-01".to_date + (s - 1) * 180, 
          end_date: "2014-01-01".to_date + (s * 180) - 1, 
          plan_id: mp.id, 
          adults_one: 20 + 4 * r_index*mp_index + rand(15), 
          adults_two: 17 + 3 * r_index*mp_index + rand(12), 
          adults_three: 15 + 2 * r_index*mp_index + rand(10), 
          children_one: 10 + 2 * r_index*mp_index + rand(7), 
          children_two: 8 + 1 * r_index*mp_index + rand(5), 
          adults_extra: 35, 
          max_adults: 2, 
          max_children: 1, 
          children_extra: 15
        }
      end
    end
  end
end

rates.each { |rate| Spree::RateHotel.create!(rate) }





<commit_msg>modified rate generates<commit_after>room_ot = Spree::OptionType.find_by_name('room')
rooms = Spree::OptionValue.where(:option_type => room_ot)

plan_ot = Spree::OptionType.find_by_name('plan')
plans = Spree::OptionValue.where(:option_type => plan_ot)

adult_ot = Spree::OptionType.find_by_name('adult')
adults = Spree::OptionValue.where(:option_type => adult_ot)
max_adults = adults.map {|e| e.presentation.to_i }.max

child_ot = Spree::OptionType.find_by_name('child')
children = Spree::OptionValue.where(:option_type => child_ot)
max_children = children.map {|e| e.presentation.to_i }.max

seasons = 2

hotels = Spree::Product.all

hotels[1..1].each do |hotel|
  rooms.to_a.each_with_index do |room, room_index|
    plans.to_a.each_with_index do |plan, plan_index|
      for s in 1..seasons
        Spree::RateHotel.create!( {
          product: hotel, 
          room_id: room.id, 
          start_date: "2014-01-01".to_date + (s - 1) * 180, 
          end_date: "2014-01-01".to_date + (s * 180) - 1, 
          plan_id: plan.id, 
          adults_one: 20 + 4 * room_index * plan_index + rand(15), 
          adults_two: 17 + 3 * room_index * plan_index + rand(12), 
          adults_three: 15 + 2 * room_index * plan_index + rand(10), 
          children_one: 10 + 2 * room_index * plan_index + rand(7), 
          children_two: 8 + 1 * room_index * plan_index + rand(5), 
          adults_extra: 35, 
          max_adults: max_adults, 
          max_children: 1, # max_children, 
          children_extra: 15
        } )
      end
    end
  end
end







{'fraction_non_alphanumeric': 0.13028953229398663, 'fraction_numerical': 0.04305864884929473, 'mean_word_length': 2.472938144329897, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3808228', 'n_tokens_mistral': 1100, 'n_tokens_neox': 974, 'n_words': 197}