To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / extra / soundsoftware / get-statistics.rb @ 984:8b6acaabe2da

History | View | Annotate | Download (1.61 KB)

1
# this script will get stats from the repo and print them to stdout
2

    
3
# USAGE: 
4

    
5
# ./script/runner -e production extra/soundsoftware/get-statistics.rb 
6
#
7

    
8
d1 = Date.parse("20101201") # => 1 Dec 2010
9
d2 = Date.today
10

    
11
def months_between(d1, d2)
12
   months = []
13
   start_date = Date.civil(d1.year, d1.month, 1)
14
   end_date = Date.civil(d2.year, d2.month, 1)
15

    
16
   raise ArgumentError unless d1 <= d2
17

    
18
   while (start_date < end_date)
19
     months << start_date
20
     start_date = start_date >>1
21
   end
22

    
23
   months << end_date
24
end
25

    
26
def weeks_between(d1, d2)
27
   weeks = []
28
   start_date = Date.civil(d1.year, d1.month, d1.day)
29
   end_date = Date.civil(d2.year, d2.month, d2.day)
30

    
31
   raise ArgumentError unless d1 <= d2
32

    
33
   while (start_date < end_date)
34
     weeks << start_date
35
     start_date = start_date + 1.week
36
   end
37

    
38
   weeks << end_date
39
end
40

    
41
# dates = months_between(d1, d2)
42
dates = weeks_between(d1, d2)
43

    
44
dates.each do |date|
45
  users =  User.find(:all, :conditions => {:created_on  => d1..date})
46
  all_projects =  Project.find(:all, :conditions => {:created_on  => d1..date})
47
  private_projects =  Project.find(:all, :conditions => {:created_on  => d1..date, 
48
                                                          :is_public => false})
49
  top_level_and_private_projects =  Project.find(:all, :conditions => {:created_on  => d1..date,
50
                                                                        :is_public => false, 
51
                                                                        :parent_id => nil})
52

    
53
  puts "#{date} #{users.count} #{all_projects.count} #{private_projects.count} #{top_level_and_private_projects.count}\n"
54

    
55
end
56

    
57

    
58

    
59