started on the real stats page
This commit is contained in:
parent
9a77d3518f
commit
190332308b
3 changed files with 89 additions and 3 deletions
|
|
@ -31,7 +31,29 @@ class AdminsController < ApplicationController
|
||||||
|
|
||||||
def stats
|
def stats
|
||||||
@popular_tags = ActsAsTaggableOn::Tagging.joins(:tag).limit(15).count(:group => :tag, :order => 'count(taggings.id) DESC')
|
@popular_tags = ActsAsTaggableOn::Tagging.joins(:tag).limit(15).count(:group => :tag, :order => 'count(taggings.id) DESC')
|
||||||
@new_posts = Post.where(:type => ['StatusMessage','ActivityStreams::Photo'],
|
|
||||||
:public => true).order('created_at DESC').limit(15).all
|
[Post, Comment, AspectMembership, User].each do |model|
|
||||||
|
create_hash(model)
|
||||||
|
end
|
||||||
|
|
||||||
|
@posts[:new_public] = Post.where(:type => ['StatusMessage','ActivityStreams::Photo'],
|
||||||
|
:public => true).order('created_at DESC').limit(15).all
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def percent_change(today, yesterday)
|
||||||
|
sprintf( "%0.02f", ((today-yesterday) / yesterday.to_f)*100).to_f
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_hash(model)
|
||||||
|
plural = model.to_s.underscore.pluralize
|
||||||
|
eval(<<DATA
|
||||||
|
@#{plural} = {
|
||||||
|
:yesterday => #{model}.where(:created_at => ((Time.now.midnight - 1.day)..Time.now.midnight)).count,
|
||||||
|
:today => #{model}.where(:created_at => ((Time.now.midnight)..Time.now)).count
|
||||||
|
}
|
||||||
|
@#{plural}[:change] = percent_change(@#{plural}[:today], @#{plural}[:yesterday])
|
||||||
|
DATA
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,62 @@
|
||||||
|
|
||||||
.span-24.last
|
.span-24.last
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%h1
|
||||||
|
Usage Statistics
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
|
||||||
|
%hr
|
||||||
|
.clearfix
|
||||||
|
|
||||||
|
.span-24.last
|
||||||
|
|
||||||
|
%h3
|
||||||
|
New Today
|
||||||
|
|
||||||
|
- [:posts, :comments, :aspect_memberships, :users].each do |name|
|
||||||
|
- model = eval("@#{name.to_s}")
|
||||||
|
- if name == :aspect_memberships
|
||||||
|
- name = :shares
|
||||||
|
|
||||||
|
.span-6{:class => ('last' if name == :users)}
|
||||||
|
%h2{:style => 'font-weight:bold;'}
|
||||||
|
= model[:today]
|
||||||
|
= name.to_s
|
||||||
|
%h4
|
||||||
|
= model[:yesterday]
|
||||||
|
|
||||||
|
%span.percent_change{:class => (model[:change] > 0 ? "green" : "red")}
|
||||||
|
= "(#{model[:change]}%)"
|
||||||
|
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%hr
|
||||||
|
|
||||||
|
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
|
||||||
|
.span-24.last
|
||||||
|
%h2
|
||||||
|
Misc Stuff
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
|
||||||
%h3
|
%h3
|
||||||
= for tg in @popular_tags
|
= for tg in @popular_tags
|
||||||
= link_to tg, tags_path(tg)
|
= link_to tg, tags_path(tg)
|
||||||
|
|
@ -10,7 +68,7 @@
|
||||||
%h3
|
%h3
|
||||||
New public posts
|
New public posts
|
||||||
.stream
|
.stream
|
||||||
= render 'shared/stream', :posts => @new_posts
|
= render 'shared/stream', :posts => @new_public_posts
|
||||||
|
|
||||||
.span-12.last
|
.span-12.last
|
||||||
%h3
|
%h3
|
||||||
|
|
|
||||||
|
|
@ -3388,3 +3388,9 @@ ul#getting_started
|
||||||
:background-color #aaa
|
:background-color #aaa
|
||||||
&:hover
|
&:hover
|
||||||
:opacity .85 !important
|
:opacity .85 !important
|
||||||
|
|
||||||
|
.red
|
||||||
|
:color $red
|
||||||
|
|
||||||
|
.green
|
||||||
|
:color green
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue