Revision 970:6bd8364eafae extra/soundsoftware

View differences:

extra/soundsoftware/get-statistics.rb
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, 1)
29
   end_date = Date.civil(d2.year, d2.month, 1)
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

  
42
users = []
43
# dates = months_between(d1, d2)
44
dates = weeks_between(d1, d2)
45
private_projects = []
46
all_projects = []
47
public_projects = []
48
top_level_and_private_projects = []
49

  
50

  
51
dates.each do |date|
52
  users <<  User.find(:all, :conditions => {:created_on  => d1..date})
53
  all_projects <<  Project.find(:all, :conditions => {:created_on  => d1..date})
54
  private_projects <<  Project.find(:all, :conditions => {:created_on  => d1..date, 
55
                                                          :is_public => false})
56
  top_level_and_private_projects <<  Project.find(:all, :conditions => {:created_on  => d1..date,
57
                                                                        :is_public => false, 
58
                                                                        :parent_id => nil})
59

  
60
  puts "#{date} #{users.size} #{all_projects.size} #{private_projects.size} \n"
61

  
62
end
63

  
64

  
65

  
66

  
67

  
68

  
69

  
70

  
71
#nusers.each_with_index do |num, idx|
72
#  puts "#{dates[idx]} #{num}\n"
73
#end
74

  
75

  
76

  
77
 
78

  

Also available in: Unified diff