From 7df883eaf046f190c49e9545f935570983fd9a60 Mon Sep 17 00:00:00 2001 From: danielgrippi <danielgrippi@gmail.com> Date: Thu, 11 Aug 2011 18:52:31 -0700 Subject: [PATCH] added summary text per user on stats --- app/controllers/admins_controller.rb | 6 ++++ app/views/admins/stats.html.haml | 51 +++++++++++++++------------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/app/controllers/admins_controller.rb b/app/controllers/admins_controller.rb index b1226e344f..07459baace 100644 --- a/app/controllers/admins_controller.rb +++ b/app/controllers/admins_controller.rb @@ -35,12 +35,16 @@ class AdminsController < ApplicationController case params[:range] when "week" range = 1.week + @segment = "week" when "2weeks" range = 2.weeks + @segment = "2 week" when "month" range = 1.month + @segment = "month" else range = 1.day + @segment = "daily" end [Post, Comment, AspectMembership, User].each do |model| @@ -50,6 +54,8 @@ class AdminsController < ApplicationController @posts_per_day = Post.count(:group => "DATE(created_at)", :conditions => ["created_at >= ?", Date.today - 21.days], :order => "DATE(created_at) ASC") @most_posts_within = @posts_per_day.values.max.to_f + @user_count = User.count + #@posts[:new_public] = Post.where(:type => ['StatusMessage','ActivityStreams::Photo'], # :public => true).order('created_at DESC').limit(15).all diff --git a/app/views/admins/stats.html.haml b/app/views/admins/stats.html.haml index f0884e8d13..d90d9db770 100644 --- a/app/views/admins/stats.html.haml +++ b/app/views/admins/stats.html.haml @@ -4,6 +4,26 @@ %br %h1 Usage Statistics + %div{:style => "float:right;"} + = form_tag('/admins/stats', :method => 'get') do + %select{:name => 'range'} + %option{:value => 'daily', :selected => ('selected' if params[:range] == 'daily')} + Daily + %option{:value => 'week', :selected => ('selected' if params[:range] == 'week')} + Week + %option{:value => '2weeks', :selected => ('selected' if params[:range] == '2weeks')} + 2 Weeks + %option{:value => 'month', :selected => ('selected' if params[:range] == 'month')} + Month + + = submit_tag 'go' + %br + %h3 + Displaying results from the + %b + = @segment + segment + %br %br %br @@ -12,27 +32,6 @@ .clearfix .span-24.last - - %div{:style => "float:right;"} - = form_tag('/admins/stats', :method => 'get') do - %select{:name => 'range'} - %option{:value => 'daily', :selected => ('selected' if params[:range] == 'daily')} - Daily - %option{:value => 'week', :selected => ('selected' if params[:range] == 'week')} - Week - %option{:value => '2weeks', :selected => ('selected' if params[:range] == '2weeks')} - 2 Weeks - %option{:value => 'month', :selected => ('selected' if params[:range] == 'month')} - Month - - = submit_tag 'go' - - %h3 - Results from the - %b - = params[:range] - segment - - [:posts, :comments, :aspect_memberships, :users].each do |name| - model = eval("@#{name.to_s}") - if name == :aspect_memberships @@ -54,8 +53,14 @@ %br %hr - %br - %br + + %p{:style => "text-align:center;"} + The current segment is averaging + %b + #{@posts[:yesterday]/@user_count.to_f} + posts per user, from + %b + #{@posts[:day_before]/@user_count.to_f} /%h3 / Posts over time -- GitLab