generate_seats

in mongodb/sampledb/v1/schema/load_sport_location.rb [69:112]


def generate_seats(capacity, levels, sections)
  seats = {:luxury => [], :premium => [], :standard => [], :subStandard => [], :obstructed => []}

  tot_seats = 0;
  min_rows = 15    
  max_rows = 25    

  (1..levels).each do |i|
    (1..sections).each do |j|

      rows = rand(min_rows..max_rows)
      seats_in_row = capacity/(levels*sections*rows) + 1

      (1..rows).each do |r|
        (1..seats_in_row).each do |s|

          tot_seats += 1

          case rand(1..100)
          when 1..5
            seat_type = 'luxury'        
          when 6..35
            seat_type = 'premium'       
          when 36..89
            seat_type = 'standard'      
          when 90..99
            seat_type = 'subStandard'  
          when 100
            seat_type = 'obstructed'    
          end

          row = 'abcdefghijklmnopqrstuvwxyz'[r]

          seat = i.to_s + '.' + j.to_s + '.' + row.to_s + '.' + s.to_s

          seats[seat_type.to_sym] << seat

        end
      end
    end
  end
  seats
end