Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added oldest pending days graph

  • Loading branch information...
commit 4244dbd0a090979bd9d8f98ede8d69f14a6ea765 1 parent 5a26eab
@spob authored
View
7 app/controllers/forums_controller.rb
@@ -79,6 +79,7 @@ def metrics_graphs
@open_count_graph = open_flash_chart_object(800, 450, open_count_graphs_forums_path)
@pending_count_graph = open_flash_chart_object(800,450, pending_count_graphs_forums_path)
@days_pending_graph = open_flash_chart_object(800, 450, days_pending_graphs_forums_path)
+ @oldest_days_pending_graph = open_flash_chart_object(800, 450, oldest_days_pending_graphs_forums_path)
end
def calc_metric_graph chart_title, y_legend
@@ -156,6 +157,10 @@ def days_pending_graphs
render :text => calc_metric_graph("Average Days Pending Response", "Days"){|i| i.days_pending }, :layout => false
end
+ def oldest_days_pending_graphs
+ render :text => calc_metric_graph("Oldest Days Pending Response", "Days"){|i| i.oldest_pending_days || 0.0 }, :layout => false
+ end
+
def create
params[:forum][:mediator_ids] ||= []
params[:forum][:group_ids] ||= []
@@ -336,8 +341,6 @@ def do_rjs_toggle_forum_details_box
end
end
- private
-
def fetch_forum
@forum = Forum.find(params[:id])
end
View
5 app/models/forum_metric.rb
@@ -1,8 +1,8 @@
class ForumMetric < ActiveRecord::Base
belongs_to :enterprise
-
+
named_scope :recent, :conditions => ["as_of > ?", 2.months.ago]
-
+
def self.calculate
enterprise_ids = User.mediators.all(:select => "distinct users.enterprise_id").collect(&:enterprise_id).find_all{|e| Topic.by_enterprise(e).owned.open.present? }
enterprise_ids = (enterprise_ids + ForumMetric.recent.collect(&:enterprise_id)).uniq
@@ -13,6 +13,7 @@ def self.calculate
metric.days_pending = (open_topics.inject(0){|sum, item| sum + item.days_comment_pending}/open_topics.size) if open_topics.size > 0
metric.open_count = open_topics.size
metric.pending_count = open_topics.find_all{|t| t.days_comment_pending > 0}.size
+ metric.oldest_pending_days = open_topics.collect{|item| item.days_comment_pending}.sort.last || 0.0
metric.save!
end
end
View
7 app/views/forums/metrics_graphs.html.erb
@@ -1,7 +1,7 @@
<%content_for :head do -%>
- <%= javascript_include_tag "swfobject" %>
+ <%= javascript_include_tag "swfobject" %>
<%end%>
-<%= javascript_include_tag "wz_tooltip.js", :cache => "cache/tooltip" %>
+<%= javascript_include_tag "wz_tooltip.js", :cache => "cache/tooltip" %>
<h1>Forum Management Metrics</h1>
<div id="actionButtons2">
@@ -17,3 +17,6 @@
<br />
<br />
<%= @days_pending_graph %>
+<br />
+<br />
+<%= @oldest_days_pending_graph %>
View
3  config/routes.rb
@@ -23,7 +23,8 @@
:collection => {:search => :get, :auto_complete_for_enterprise_name => :get}
map.resources :forums, :collection => {:search => :get,
:rss => :get, :tag => :get, :metrics => :get, :metrics_graphs => :get,
- :open_count_graphs => :get, :days_pending_graphs => :get, :pending_count_graphs => :get},
+ :open_count_graphs => :get, :days_pending_graphs => :get,
+ :pending_count_graphs => :get, :oldest_days_pending_graphs => :get},
:member => {:mark_all_as_read => :post}
map.resources :groups
map.resources :link_sets, :member => {:update_sort => :post}
View
13 db/migrate/20110119011501_add_oldest_pending_days.rb
@@ -0,0 +1,13 @@
+class AddOldestPendingDays < ActiveRecord::Migration
+ def self.up
+ change_table :forum_metrics do |t|
+ t.decimal :oldest_pending_days
+ end
+ end
+
+ def self.down
+ change_table :forum_metrics do |t|
+ t.remove :oldest_pending_days
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.