Created
August 31, 2009 23:47
-
-
Save imownbey/178782 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setup_sightings_for_rollup | |
timespans = [ # [start_time, end_time, quantity, values] | |
[1.minute.ago, Time.now, 250, [1]], | |
[1.hour.ago, 1.minute.ago, 5000, [1]], | |
[1.day.ago, 1.hour.ago, 1500, [1, 2]], | |
[1.week.ago, 1.day.ago, 1000, [1, 2]], | |
[3.weeks.ago, 1.week.ago, 500, [1, 2]] | |
] | |
cities = { # city => divisor (for quantity) | |
'Atlanta' => 1, | |
'Roswell' => 10 | |
} | |
observers = %w(Mike Bill Mary Joe) | |
format = Factory :format_ufo_sightings | |
Tempfile.open 'ufo_sightings' do |file| | |
cities.each do |city, divisor| | |
timespans.each do |start_time, end_time, quantity, values| | |
duration = end_time - 1.second - start_time | |
quantity /= divisor | |
quantity.times do |i| | |
time = start_time + duration * i / (quantity - 1) | |
values[i % values.length].times do | |
file.puts "#{time.to_i} #{(time.to_i / 60) * 60} #{(time.to_i / 3600) * 3600} #{city} #{observers.rand}" | |
end | |
end | |
end | |
end | |
file.flush | |
format.load file.path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment