Created
May 3, 2013 01:56
-
-
Save khoan/5506733 to your computer and use it in GitHub Desktop.
This file contains 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
class SimulateTraffic | |
def initialize | |
@dates = (first_date_of_last_month..Date.today).to_a | |
@types = [:pageviews, :subscriptions, :shares, :clicks] | |
end | |
def first_date_of_last_month | |
prev_month = Date.today.prev_month | |
Date.new(prev_month.year, prev_month.month, 1) | |
end | |
def fake_daily | |
hourly_count = 24.times.map{rand(1000)} | |
DailyStat.create edition_id: Edition.first.id, date: @dates.sample, hourly_count: hourly_count, type: @types.sample, total: hourly_count.sum | |
end | |
end | |
simulator = SimulateTraffic.new | |
100.times do | |
simulator.fake_daily | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment