Module: Headcount::History::ClassMethods

Defined in:
lib/headcount/history.rb

Instance Method Summary collapse

Instance Method Details

#seed(start, interval) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/headcount/history.rb', line 6

def seed(start, interval)
  time = start
  now = DateTime.now
  headcounts = []
  
  while time < now
    headcounts << Headcount.count(time)
    time += interval
  end
  
  headcounts
end

#seed!(start, interval) ⇒ Object



19
20
21
22
23
# File 'lib/headcount/history.rb', line 19

def seed!(start, interval)
  seed(start, interval).tap do |headcounts|
    persist(headcounts, {:reset => true})
  end
end