Modified:
trunk/seb/app/controllers/stats_controller.rb
trunk/seb/app/models/item.rb
trunk/seb/app/views/stats/summary.rhtml
Log:
added per_day_of_week pie chart
Modified: trunk/seb/app/controllers/stats_controller.rb
==============================================================================
--- trunk/seb/app/controllers/stats_controller.rb (original)
+++ trunk/seb/app/controllers/stats_controller.rb Sun Apr 20 15:02:22 2008
@@ -10,6 +10,7 @@
def summary
@graph = open_flash_chart_object(600,300, '/stats/per_day', false)
@months = open_flash_chart_object(600,300, '/stats/per_month', false)
+ @days= open_flash_chart_object(600,300,'/stats/per_day_of_week', false)
end
def per_day
@@ -52,6 +53,20 @@
@top=@item_counts.max/250+1
g.set_y_max(@top*250)
g.set_y_label_steps(@top)
+ render :text => g.render
+ end
+
+ def per_day_of_week
+ @item_counts=[]
+ 1.upto(7) do |i|
+ @item_counts<<Item.day_of_week_count(i)
+ end
+ g = Graph.new
+ g.pie(60, '#505050', '{font-size: 12px; color: #404040;}')
+ g.pie_values(@item_counts, %w(Saturday Sunday Monday Tuesday
Wednesday Thursday Friday))
+ g.pie_slice_colors(%w(#99FF66 #CC6699 #FF9966 #339999))
+ g.set_tool_tip("#val#")
+ g.title("Posts by Day of the Week", '{font-size:18px; color:
#d01f3c}' )
render :text => g.render
end
Modified: trunk/seb/app/models/item.rb
==============================================================================
--- trunk/seb/app/models/item.rb (original)
+++ trunk/seb/app/models/item.rb Sun Apr 20 15:02:22 2008
@@ -25,5 +25,9 @@
def Item.time_of_day_count(hour)
Item.find(:all, :conditions=>"HOUR(TIME(pubDate))='#{hour}'").length
rescue 0
end
+
+ def Item.day_of_week_count(day)
+ Item.find(:all, :conditions=>["dayofweek(pubDate)=?",day]).length
rescue nil
+ end
end
Modified: trunk/seb/app/views/stats/summary.rhtml
==============================================================================
--- trunk/seb/app/views/stats/summary.rhtml (original)
+++ trunk/seb/app/views/stats/summary.rhtml Sun Apr 20 15:02:22 2008
@@ -1,3 +1,4 @@
<h1> Scotedublogs Statistics</h1>
<div class="stat_image"><%= @graph %></div>
<div class="stat_image"><%= @months %></div>
+<div class="stat_image"><%= @days %></div>