# HG changeset patch # User Chris Cannam # Date 1350654434 -3600 # Node ID b80f97c892bc45cd0a4619b0f280a0c60d24089d # Parent e632838adb35372a6ca739b52a07fd90cef0cdb7# Parent 6bd8364eafaee9eb8abecc48c45a2cbee3a81708 Merge from branch "get_statistics" diff -r e632838adb35 -r b80f97c892bc extra/soundsoftware/get-statistics.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extra/soundsoftware/get-statistics.rb Fri Oct 19 14:47:14 2012 +0100 @@ -0,0 +1,78 @@ +# this script will get stats from the repo and print them to stdout + +# USAGE: + +# ./script/runner -e production extra/soundsoftware/get-statistics.rb +# + +d1 = Date.parse("20101201") # => 1 Dec 2010 +d2 = Date.today + +def months_between(d1, d2) + months = [] + start_date = Date.civil(d1.year, d1.month, 1) + end_date = Date.civil(d2.year, d2.month, 1) + + raise ArgumentError unless d1 <= d2 + + while (start_date < end_date) + months << start_date + start_date = start_date >>1 + end + + months << end_date +end + +def weeks_between(d1, d2) + weeks = [] + start_date = Date.civil(d1.year, d1.month, 1) + end_date = Date.civil(d2.year, d2.month, 1) + + raise ArgumentError unless d1 <= d2 + + while (start_date < end_date) + weeks << start_date + start_date = start_date + 1.week + end + + weeks << end_date +end + + +users = [] +# dates = months_between(d1, d2) +dates = weeks_between(d1, d2) +private_projects = [] +all_projects = [] +public_projects = [] +top_level_and_private_projects = [] + + +dates.each do |date| + users << User.find(:all, :conditions => {:created_on => d1..date}) + all_projects << Project.find(:all, :conditions => {:created_on => d1..date}) + private_projects << Project.find(:all, :conditions => {:created_on => d1..date, + :is_public => false}) + top_level_and_private_projects << Project.find(:all, :conditions => {:created_on => d1..date, + :is_public => false, + :parent_id => nil}) + + puts "#{date} #{users.size} #{all_projects.size} #{private_projects.size} \n" + +end + + + + + + + + +#nusers.each_with_index do |num, idx| +# puts "#{dates[idx]} #{num}\n" +#end + + + + +