changeset 1194:6676c0284df2 feature_564

Add "mature projects" box. This isn't good enough on its own, it's just a test -- we need this to inform other relationships
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Tue, 22 Jan 2013 17:03:50 +0000
parents d67ed1030451
children 7f94e4180a2f
files app/helpers/projects_helper.rb app/views/projects/explore.html.erb
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/app/helpers/projects_helper.rb	Tue Jan 22 16:54:14 2013 +0000
+++ b/app/helpers/projects_helper.rb	Tue Jan 22 17:03:50 2013 +0000
@@ -295,4 +295,12 @@
     end
     phash
   end
+
+  def mature_projects(count)
+    phash = all_maturity_scores
+    scores = phash.values.sort
+    threshold = scores[scores.length / 2]
+    if threshold == 0 then threshold = 1 end
+    phash.keys.select { |k| phash[k] > threshold }.sample(count)
+  end
 end
--- a/app/views/projects/explore.html.erb	Tue Jan 22 16:54:14 2013 +0000
+++ b/app/views/projects/explore.html.erb	Tue Jan 22 17:03:50 2013 +0000
@@ -6,9 +6,9 @@
     <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %>
 </div>
 
+<h2><%= l(:label_explore_projects) %></h2>
+
 <% cache(:action => 'explore', :action_suffix => 'tags', :expires_in => 1.hour) do %>
-
-<h2><%= l(:label_explore_projects) %></h2>
   <div class="tags box">
   <h3><%=l(:label_project_tags_all)%></h3>
     <%= render :partial => 'projects/tagcloud' %>
@@ -37,4 +37,10 @@
     <%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index' }, :class => 'more' %>
   </div>
   <% end %>
+  <% cache(:action => 'explore', :action_suffix => 'mature_projects', :expires_in => 1.hour) do %>
+  <div class="projects box">
+  <h3><%=l(:label_projects_mature)%></h3>
+    <%= render :partial => 'projects/mature' %>
+  </div>
+  <% end %>
 </div>