changeset 1490:b1f6665080fd

Merge from live branch
author Chris Cannam
date Mon, 17 Mar 2014 08:55:57 +0000
parents 020bc7fe7a2a (current diff) f67d6e387088 (diff)
children cb53cb6eeaef a5f2bdf3b486
files
diffstat 4 files changed, 24 insertions(+), 146 deletions(-) [+]
line wrap: on
line diff
--- a/Gemfile	Tue Oct 22 13:00:01 2013 +0100
+++ b/Gemfile	Mon Mar 17 08:55:57 2014 +0000
@@ -1,6 +1,6 @@
 source 'http://rubygems.org'
 
-gem "rails", "3.2.13"
+gem "rails", "3.2.17"
 gem "jquery-rails", "~> 2.0.2"
 gem "i18n", "~> 0.6.0"
 gem "coderay", "~> 1.0.6"
--- a/app/views/account/register.html.erb	Tue Oct 22 13:00:01 2013 +0100
+++ b/app/views/account/register.html.erb	Mon Mar 17 08:55:57 2014 +0000
@@ -22,20 +22,20 @@
 <p><%= f.text_field :lastname, :required => true %></p>
 <p><%= f.text_field :mail, :required => true %></p>
 
-<!-- We only support English in this site 
+<!-- We only support English in this site
 <p><%= f.select :language, lang_options_for_select %></p>
 -->
-    
+
 <%= labelled_fields_for :ssamr_user_details, @ssamr_user_details do |fields| %>
 <h3><%=l(:label_ssamr_details)%></h3>
- 
+
 <p>
   <%= fields.text_area :description, :rows => 3, :cols => 40, :required => true, :class => 'wiki-edit' %>
   <em> <%=l(:text_user_ssamr_description_info).html_safe%></em>
 </p>
 
 <p><label for="institution"><%=l("field_ssamr_user_detail.institution")%> <span class="required">*</span></label>
-  <%= fields.radio_button :institution_type, true %>
+  <%= fields.radio_button :institution_type, true, :checked => true %>
   <%= fields.collection_select(:institution_id, Institution.find(:all, :order => "institutions.order"), :id, :name,  {:selected => @selected_institution_id, :prompt => true}).gsub('&amp;', '&').html_safe  %>
 </p>
 
@@ -44,7 +44,7 @@
   <%= fields.text_field(:other_institution) %>
 </p>
 <% end %>
-      
+
 
 <% if Setting.openid? %>
   <p><%= f.text_field :identity_url  %></p>
--- a/config/application.rb	Tue Oct 22 13:00:01 2013 +0100
+++ b/config/application.rb	Mon Mar 17 08:55:57 2014 +0000
@@ -32,6 +32,10 @@
     # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
     # config.time_zone = 'Central Time (US & Canada)'
 
+    # Avoid deprecation warning (may want to change this later if future
+    # Redmine updates are OK with it)
+    config.i18n.enforce_available_locales = false
+
     # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
     # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
     # config.i18n.default_locale = :de
--- a/extra/soundsoftware/get-statistics.rb	Tue Oct 22 13:00:01 2013 +0100
+++ b/extra/soundsoftware/get-statistics.rb	Mon Mar 17 08:55:57 2014 +0000
@@ -1,147 +1,21 @@
-# this script will get stats from the repo and print them to stdout
 
-# USAGE: 
-
-# ./script/runner -e production extra/soundsoftware/get-statistics.rb 
+# Log user and project information
+#
+# Invoke with e.g.
+#
+# ./script/rails runner -e production extra/soundsoftware/get-statistics.rb
 #
 
-d1 = Date.parse("20100701") # => 1 Jul 2010
-d2 = Date.today
+projectStats =  {
+        :all => Project.active.all.count,
+        :private => Project.active.find(:all, :conditions => {:is_public => false}).count,
+        :top_level => Project.active.find(:all, :conditions => {:parent_id => nil}).count,
+        :top_level_and_private => Project.active.find(:all, :conditions => {:is_public => false, :parent_id => nil}).count
+      }
 
-def delta_array (iarray)
-  # returns an array with the deltas
-  ## prepends a zero and drops the last element
-  deltas = [0] + iarray
-  deltas = deltas.first(deltas.size - 1)
+userStats = {:all => User.active.all.count}
 
-  return iarray.zip(deltas).map { |x, y| x - y }
+stats = {:date => Date.today, :projects => projectStats, :users => userStats}.to_json
 
-end
+print "#{stats}\n"
 
-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, d1.day)
-   end_date = Date.civil(d2.year, d2.month, d2.day)
-
-   raise ArgumentError unless d1 <= d2
-
-   while (start_date < end_date)
-     weeks << start_date
-     start_date = start_date + 2.week
-   end
-
-   weeks << end_date
-end
-
-def get_user_project_evol_stats()
-  # dates = months_between(d1, d2)
-  dates = months_between(d1, d2)
-  
-  # number of users 
-  n_users = []
-  n_projects = []
-  qm_users = []
-  
-  dates.each do |date|
-    users =  User.find_by_sql ["SELECT * FROM users WHERE users.status = '1' AND users.created_on <= ?;", date]
-    projects =  Project.find_by_sql ["SELECT * FROM projects WHERE projects.created_on <= ?;", date]
-    
-    qm_users_list = User.find_by_sql ["SELECT * FROM users,ssamr_user_details WHERE users.status = '1' AND ssamr_user_details.user_id = users.id AND (users.mail like '%qmul%' OR ssamr_user_details.institution_id = '99') AND users.created_on <= ?;", date ]
-    
-    qm_users << qm_users_list.count
-    n_users << users.count
-    n_projects << projects.count
-    
-    #  private_projects =  Project.find(:all, :conditions => {:created_on  => d1..date, is_public => false})
-  end
-  
-  user_deltas = delta_array(n_users)
-  proj_deltas = delta_array(n_projects)
-  qm_user_deltas = delta_array(qm_users)
-  
-  puts "Date Users D_Users QM_Users D_QM_users Projects D_Projects"
-  
-  dates.zip(n_users, user_deltas, qm_users, qm_user_deltas, n_projects, proj_deltas).each do |a, b, c, d, e, f, g|
-    puts "#{a} #{b} #{c} #{d} #{e} #{f} #{g}"
-  end
-  
-end
-
-
-def get_project_status()
-  date = "20121101"
-  
-   all_projects = Project.find(:all, :conditions => ["created_on < ?", date])
-  #  all_projects = Project.find(:all, :conditions => ["is_public = ? AND created_on < ?", true, date])
-#  all_projects = Project.find(:all, :conditions => ["is_public = ? AND created_on < ?", false, date])
-  
-  collab = []
-  users_per_proj = []
-  
-  #  puts "Public Users Institutions"
-
-  all_projects.each do |proj| 
-    insts = []
-
-    proj.users.each do |u|  
-      if u.institution == "" || u.institution == "No Institution Set"
-        if u.mail.include?("qmul.ac.uk") || u.mail.include?("andrewrobertson77")
-          insts << "Queen Mary, University of London"          
-        else
-          insts << u.mail
-        end
-      else
-        insts << u.institution
-      end
-    end
-
-    users_per_proj << proj.users.count
-    collab << insts.uniq.count
-  end
-  
-  
-  #  freq = collab.inject(Hash.new(0)) { |h,v| h[v] += 1; h }
-  #  freq = freq.sort_by {|key, value| value}
-  #  puts freq.inspect.sort
-
-  puts "Projects: #{all_projects.count} UpP: #{users_per_proj.sum / users_per_proj.size.to_f} Users1+: #{users_per_proj.count{|x| x> 1}} Users2+: #{users_per_proj.count{|x| x> 2}} Collab1+: #{collab.count{|x| x > 1}} Collab2+: #{collab.count{|x| x > 2}} IpP: #{collab.sum / collab.size.to_f}"
-end
-
-def get_user_projects_ratios()
-  user_projects = User.find(:all, :conditions=> {:status => 1})
-  pub_proj_user = user_projects.map{|u| u.projects.find(:all, :conditions=>{:is_public => true}).count}
-
-  user_projects.zip(pub_proj_user).each do |u, pub|
-      puts "#{u.projects.count} #{pub}"
-  end
-
-end
-
-def get_inst_list()
-  users = User.find(:all, :conditions => {:status => 1})
-  inst_list = users.map{|user| user.institution}
-  
-  freq = inst_list.inject(Hash.new(0)) { |h,v| h[v] += 1; h }
-  
-end
-
-
-# get_user_projects_ratios()
-# get_user_project_evol_stats()
-
-get_project_status()