myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [1895] trunk: Basic "detailed statistics" page ad


From: noreply
Subject: [myexperiment-hackers] [1895] trunk: Basic "detailed statistics" page added for files / packs / workflows.
Date: Wed, 29 Oct 2008 08:07:40 -0400 (EDT)

Revision
1895
Author
alekses6
Date
2008-10-29 08:07:39 -0400 (Wed, 29 Oct 2008)

Log Message

Basic "detailed statistics" page added for files / packs / workflows.

Modified Paths

Added Paths

Diff

Modified: trunk/app/controllers/blobs_controller.rb (1894 => 1895)


--- trunk/app/controllers/blobs_controller.rb	2008-10-28 17:41:42 UTC (rev 1894)
+++ trunk/app/controllers/blobs_controller.rb	2008-10-29 12:07:39 UTC (rev 1895)
@@ -4,7 +4,7 @@
 # See license.txt for details.
 
 class BlobsController < ApplicationController
-  before_filter :login_required, :except => [:index, :show, :download, :named_download, :search, :all]
+  before_filter :login_required, :except => [:index, :show, :download, :named_download, :statistics, :search, :all]
   
   before_filter :find_blobs, : [:all]
   before_filter :find_blob_auth, :except => [:search, :index, :new, :create, :all]

Modified: trunk/app/controllers/packs_controller.rb (1894 => 1895)


--- trunk/app/controllers/packs_controller.rb	2008-10-28 17:41:42 UTC (rev 1894)
+++ trunk/app/controllers/packs_controller.rb	2008-10-29 12:07:39 UTC (rev 1895)
@@ -6,7 +6,7 @@
 class PacksController < ApplicationController
   include ApplicationHelper
   
-  before_filter :login_required, :except => [:index, :show, :all, :search, :items, :download]
+  before_filter :login_required, :except => [:index, :show, :all, :search, :items, :download, :statistics]
   
   before_filter :find_packs, : [:all]
   before_filter :find_pack_auth, :except => [:index, :new, :create, :all, :search]

Modified: trunk/app/controllers/workflows_controller.rb (1894 => 1895)


--- trunk/app/controllers/workflows_controller.rb	2008-10-28 17:41:42 UTC (rev 1894)
+++ trunk/app/controllers/workflows_controller.rb	2008-10-29 12:07:39 UTC (rev 1895)
@@ -4,7 +4,7 @@
 # See license.txt for details.
 
 class WorkflowsController < ApplicationController
-  before_filter :login_required, :except => [:index, :show, :download, :named_download, :launch, :search, :all]
+  before_filter :login_required, :except => [:index, :show, :download, :named_download, :statistics, :launch, :search, :all]
   
   before_filter :find_workflows, : [:all]
   before_filter :find_workflows_rss, : [:index]

Modified: trunk/app/models/download.rb (1894 => 1895)


--- trunk/app/models/download.rb	2008-10-28 17:41:42 UTC (rev 1894)
+++ trunk/app/models/download.rb	2008-10-29 12:07:39 UTC (rev 1895)
@@ -36,4 +36,16 @@
               :order => "count DESC",
               :limit => limit)
   end
+  
+  # returns the number of member downloads from myExperiment website 
+  # for the contribution given by ID - i.e. downloads from myExperiment
+  # website done by logged in users
+  def self.member_site_downloads_count_for_contribution(contribution_id)
+    self.count(:all, :conditions => ["contribution_id = ? AND accessed_from_site = ? AND user_id IS NOT NULL", contribution_id, true])
+  end
+  
+  # returns the number of anonymous downloads from the website for the contribution
+  def self.anonymous_site_downloads_count_for_contribution(contribution_id)
+    self.count(:all, :conditions => ["contribution_id = ? AND accessed_from_site = ? AND user_ID IS NULL", contribution_id, true])
+  end
 end

Modified: trunk/app/models/policy.rb (1894 => 1895)


--- trunk/app/models/policy.rb	2008-10-28 17:41:42 UTC (rev 1894)
+++ trunk/app/models/policy.rb	2008-10-29 12:07:39 UTC (rev 1895)
@@ -331,7 +331,8 @@
                                   "quick_add",
                                   "resolve_link"], 
                    "view" =>     ["index", 
-                                  "show", 
+                                  "show",
+                                  "statistics",
                                   "search", 
                                   "favourite",
                                   "favourite_delete",

Modified: trunk/app/models/viewing.rb (1894 => 1895)


--- trunk/app/models/viewing.rb	2008-10-28 17:41:42 UTC (rev 1894)
+++ trunk/app/models/viewing.rb	2008-10-29 12:07:39 UTC (rev 1895)
@@ -39,4 +39,16 @@
               :order => "count DESC",
               :limit => limit)
   end
+  
+  # returns the number of member viewings from myExperiment website 
+  # for the contribution given by ID - i.e. viewings from myExperiment
+  # website done by logged in users
+  def self.member_site_viewings_count_for_contribution(contribution_id)
+    self.count(:all, :conditions => ["contribution_id = ? AND accessed_from_site = ? AND user_id IS NOT NULL", contribution_id, true])
+  end
+  
+  # returns the number of anonymous viewings from the website for the contribution
+  def self.anonymous_site_viewings_count_for_contribution(contribution_id)
+    self.count(:all, :conditions => ["contribution_id = ? AND accessed_from_site = ? AND user_ID IS NULL", contribution_id, true])
+  end
 end

Added: trunk/app/views/blobs/statistics.rhtml (0 => 1895)


--- trunk/app/views/blobs/statistics.rhtml	                        (rev 0)
+++ trunk/app/views/blobs/statistics.rhtml	2008-10-29 12:07:39 UTC (rev 1895)
@@ -0,0 +1 @@
+<%= render :partial => "contributions/statistics_detailed", :locals => { :contributable => @blob } %>
\ No newline at end of file

Modified: trunk/app/views/contributions/_statistics_box.rhtml (1894 => 1895)


--- trunk/app/views/contributions/_statistics_box.rhtml	2008-10-28 17:41:42 UTC (rev 1894)
+++ trunk/app/views/contributions/_statistics_box.rhtml	2008-10-29 12:07:39 UTC (rev 1895)
@@ -56,6 +56,9 @@
 	    	<a href="" pluralize contributable.comments_count, "comment" -%></a>
 	    </p>
 		<% end -%>
-			
+		
+		<p style="text-align: right; margin-top: 0.3em;">
+		  <small>[ <%= link_to "view more", eval("statistics_#{controller_visible_name(type.to_s.pluralize).singularize.downcase}_path(#{contributable.id})") -%> ]</small>
+		</p>	
 	</div>
 </div>
\ No newline at end of file

Added: trunk/app/views/contributions/_statistics_detailed.rhtml (0 => 1895)


--- trunk/app/views/contributions/_statistics_detailed.rhtml	                        (rev 0)
+++ trunk/app/views/contributions/_statistics_detailed.rhtml	2008-10-29 12:07:39 UTC (rev 1895)
@@ -0,0 +1,73 @@
+<% c_ution = contributable.contribution -%>
+<% contributable_display_type = controller_visible_name(contributable.class.to_s.pluralize).singularize %>
+
+<% total_viewings = c_ution.viewings_count -%>
+<% internal_member_viewings = Viewing.member_site_viewings_count_for_contribution(c_ution.id) -%>
+<% internal_anonymous_viewings = Viewing.anonymous_site_viewings_count_for_contribution(c_ution.id) -%>
+<% site_viewings = internal_member_viewings + internal_anonymous_viewings -%>
+
+<% total_downloads = c_ution.downloads_count -%>
+<% internal_member_downloads = Download.member_site_downloads_count_for_contribution(c_ution.id) -%>
+<% internal_anonymous_downloads = Download.anonymous_site_downloads_count_for_contribution(c_ution.id) -%>
+<% site_downloads = internal_member_downloads + internal_anonymous_downloads -%>
+
+
+<ul class="sectionIcons">
+	<li><%= icon(contributable.class.to_s.downcase, eval("#{contributable_display_type.downcase}_path(#{contributable.id})"), nil, nil, "Back to the #{contributable_display_type}") %></li>
+</ul>
+
+<% # this will be changed to display the correct thing after event logging branch is merged into trunk %>
+<h1 class="contribution_title">
+	<%= contributable_display_type -%> Statistics: <%= link_to_function (h(contributable.title) + expand_image), visual_effect(:toggle_blind, "contributable_box", :duration => 0.3) -%>
+</h1>
+
+<div id="contributable_box" style="display: none; margin: 1em 0 1em 0;">
+ <%= render :partial => "#{contributable.class.to_s.pluralize}/table", :locals => { :collection => [ contributable ] } %>
+</div>
+
+<center>
+	<div class="box_standout" style="width: 400px; text-align: center; margin-top: 2em;">
+		<table>
+			<tr>
+				<th>Viewings (<%= total_viewings -%>)</th>
+				<th style="padding-left: 3em;">Downloads (<%= total_downloads -%>)</th>
+			</tr>
+			<tr>
+				<td style="text-align: left; vertical-align: top;">
+					From myExperiment (<%= site_viewings -%>)
+					<%= info_icon_with_tooltip("Viewings made by following links to this #{contributable_display_type} from myExperiment website.") -%>
+					<ul style="margin-top: 0.3em; margin-bottom: 0em;">
+						<li>
+							Members: <%= internal_member_viewings -%>
+						</li>
+						<li>
+							Anonymous: <%= internal_anonymous_viewings -%>
+						</li>
+					</ul>
+				</td>
+				<td style="text-align: left; vertical-align: top; padding-left: 3em;">
+					From myExperiment (<%= site_downloads -%>)
+					<%= info_icon_with_tooltip("Downloads made by following links to this #{contributable_display_type} from myExperiment website.") -%>
+					<ul style="margin-top: 0.3em; margin-bottom: 0em;">
+						<li>
+							Members: <%= internal_member_downloads -%>
+						</li>
+						<li>
+							Anonymous: <%= internal_anonymous_downloads -%>
+						</li>
+					</ul>
+				</td>
+			</tr>
+			<tr>
+				<td style="text-align: left; vertical-align: top;">
+					External accesses (<%= total_viewings - site_viewings -%>)
+					<%= info_icon_with_tooltip("Viewings made by accessing this #{contributable_display_type} via direct links and API.") -%>
+				</td>
+				<td style="text-align: left; vertical-align: top; padding-left: 3em;">
+					External accesses (<%= total_downloads - site_downloads -%>)
+					<%= info_icon_with_tooltip("Downloads made by accessing this #{contributable_display_type} via direct links and API.") -%>
+				</td>
+			</tr>
+		</table>
+	</div>
+</center>

Added: trunk/app/views/packs/statistics.rhtml (0 => 1895)


--- trunk/app/views/packs/statistics.rhtml	                        (rev 0)
+++ trunk/app/views/packs/statistics.rhtml	2008-10-29 12:07:39 UTC (rev 1895)
@@ -0,0 +1 @@
+<%= render :partial => "contributions/statistics_detailed", :locals => { :contributable => @pack } %>
\ No newline at end of file

Added: trunk/app/views/workflows/statistics.rhtml (0 => 1895)


--- trunk/app/views/workflows/statistics.rhtml	                        (rev 0)
+++ trunk/app/views/workflows/statistics.rhtml	2008-10-29 12:07:39 UTC (rev 1895)
@@ -0,0 +1 @@
+<%= render :partial => "contributions/statistics_detailed", :locals => { :contributable => @workflow } %>
\ No newline at end of file

Modified: trunk/config/routes.rb (1894 => 1895)


--- trunk/config/routes.rb	2008-10-28 17:41:42 UTC (rev 1894)
+++ trunk/config/routes.rb	2008-10-29 12:07:39 UTC (rev 1895)
@@ -46,6 +46,7 @@
     :collection => { :all => :get, :search => :get }, 
     :member => { :comment => :post, 
                  :comment_delete => :delete,
+                 :statistics => :get,
                  :favourite => :post,
                  :favourite_delete => :delete,
                  :tag => :post,
@@ -68,6 +69,7 @@
     :member => { :new_version => :get, 
                  :download => :get, 
                  :launch => :get,
+                 :statistics => :get,
                  :favourite => :post, 
                  :favourite_delete => :delete, 
                  :comment => :post, 
@@ -89,7 +91,8 @@
   map.resources :files, 
     :controller => :blobs, 
     :collection => { :all => :get, :search => :get }, 
-    :member => { :download => :get, 
+    :member => { :download => :get,
+                 :statistics => :get,
                  :favourite => :post,
                  :favourite_delete => :delete,
                  :comment => :post, 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]