[scotedublog commit] r156 - in trunk/seb/app: controllers models views/stats

0 views
Skip to first unread message

codesite...@google.com

unread,
Apr 23, 2008, 4:16:36 PM4/23/08
to scotedubl...@googlegroups.com
Author: jonesieboy
Date: Wed Apr 23 13:16:17 2008
New Revision: 156

Modified:
trunk/seb/app/controllers/stats_controller.rb
trunk/seb/app/models/item.rb
trunk/seb/app/views/stats/summary.rhtml

Log:
added per_authority graph to stats


Modified: trunk/seb/app/controllers/stats_controller.rb
==============================================================================
--- trunk/seb/app/controllers/stats_controller.rb (original)
+++ trunk/seb/app/controllers/stats_controller.rb Wed Apr 23 13:16:17 2008
@@ -1,7 +1,7 @@
class StatsController < ApplicationController
caches_page :per_day
caches_page :per_month
-
+ caches_page :per_authority
def index
summary
render :action => 'summary'
@@ -11,6 +11,7 @@
@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)
+ @authorities=open_flash_chart_object(600,600,'/stats/per_authority',false)
end

def per_day
@@ -70,32 +71,24 @@
render :text => g.render
end

- def testing
- g = Graph.new
- g.title( 'Users vs. Ram - 24h statistics', '{color: #7E97A6;
font-size: 20; text-align: center}' )
- g.set_bg_color('#FFFFFF')
- g.set_data([289,198,143,126,98,96,124,164,213,238,256,263,265,294,291,289,306,341,353,353,402,419,404,366,309])
- g.line_dot( 2, 4, '#818D9D', 'Max Users', 10 )
- g.set_data([698,1101,1324,1396,1568,1571,1496,1349,1140,1045,966,926,906,754,766,757,672,510,431,436,227,533,566,744,1004])
- g.line_hollow( 2, 4, '#164166', 'Free Ram', 10 )
- g.attach_to_y_right_axis(2)
- g.set_y_max(600)
- g.set_y_right_max(1700)
- g.set_x_axis_color('#818D9D', '#F0F0F0' )
- g.set_y_axis_color( '#818D9D', '#ADB5C7' )
- g.y_right_axis_color('#164166' )
- g.set_x_legend( 'My IRC Server', 12, '#164166' )
- g.set_y_legend( 'Max Users', 12, '#164166' )
- g.set_y_legend_right( 'Free Ram (MB)' ,12 , '#164166' )
- tmp = []
- (0..25).to_a.each do |x|
- tmp << "#{x}:00"
- end
- g.set_x_labels(tmp)
- g.set_x_label_style(10, '#164166', 0, 3, '#818D9D' )
- g.set_y_label_steps(5)
-
- render :text => g.render
+ def per_authority
+ @labels=[]
+ bar1 = Bar.new(50, '#0066CC')
+ bar1.key('Posts', 10)
+ Authority.find(:all).each do |auth|
+ bar1.data << Item.authority_count(auth.id)
+ @labels << auth.name.chomp("Council")
+ end
+ g=Graph.new
+ g.title("Posts per Authority", "{font-size: 26px;}")
+ g.data_sets << bar1
+ g.set_x_labels(@labels)
+ g.set_x_label_style(10, '#9933CC', 2)
+ g.set_x_axis_steps(1)
+ g.set_y_max(4000)
+ g.set_y_label_steps(40)
+ g.set_y_legend("Posts", 12, "0x736AFF")
+ render :text => g.render
end

def hourly

Modified: trunk/seb/app/models/item.rb
==============================================================================
--- trunk/seb/app/models/item.rb (original)
+++ trunk/seb/app/models/item.rb Wed Apr 23 13:16:17 2008
@@ -29,5 +29,9 @@
def Item.day_of_week_count(day)
Item.find(:all, :conditions=>["dayofweek(pubDate)=?",day]).length
rescue nil
end
+
+ def Item.authority_count(authority_id)
+ Item.find_by_sql(["select items.* from items, feeds where
items.feed_id=feeds.id and feeds.authority_id=?",authority_id]).length
rescue 0
+ 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 Wed Apr 23 13:16:17 2008
@@ -2,3 +2,4 @@
<div class="stat_image"><%= @graph %></div>
<div class="stat_image"><%= @months %></div>
<div class="stat_image"><%= @days %></div>
+<div class="stat_image"><%= @authorities %></div>

Reply all
Reply to author
Forward
0 new messages