extract_statistics
1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/environment'
date = Person.find(:first, :order => :created_at).created_at
file = File.open('data.csv', 'w+')
file.write("Numero de pessoas por mes\n")
puts "Numero de pessoas por mes"
while(date <= Date.today) do
date = date.beginning_of_month
amount = Person.count(:conditions => {:created_at => date...date.end_of_month})
file.write("#{date.strftime('%m/%Y')},#{amount}\n")
puts "Amount in #{date.strftime('%m/%Y')} #{amount}"
date = date.next_month
end
file.write("Numero de comunidades por mes\n")
puts "Numero de comunidades por mes"
date = Community.find(:first, :order => :created_at).created_at
while(date <= Date.today) do
date = date.beginning_of_month
amount = Community.count(:conditions => {:created_at => date...date.end_of_month})
file.write("#{date.strftime('%m/%Y')},#{amount}\n")
puts "Amount in #{date.strftime('%m/%Y')} #{amount}"
date = date.next_month
end
file.write("Numero de artigos por mes\n")
puts "Numero de artigos por mes"
date = Article.find(:first, :order => :created_at).created_at
while(date <= Date.today) do
date = date.beginning_of_month
amount = Article.count(:conditions => {:created_at => date...date.end_of_month})
file.write("#{date.strftime('%m/%Y')},#{amount}\n")
puts "Amount in #{date.strftime('%m/%Y')} #{amount}"
date = date.next_month
end
file.close