go off of yesterday's stats (full day comparison)

This commit is contained in:
danielgrippi 2011-08-11 17:27:20 -07:00
parent 190332308b
commit 2d9b9270cb
2 changed files with 5 additions and 5 deletions

View file

@ -49,10 +49,11 @@ class AdminsController < ApplicationController
plural = model.to_s.underscore.pluralize
eval(<<DATA
@#{plural} = {
:day_before => #{model}.where(:created_at => ((Time.now.midnight - 2.days)..Time.now.midnight - 1.day)).count,
: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])
@#{plural}[:change] = percent_change(@#{plural}[:yesterday], @#{plural}[:day_before])
DATA
)
end

View file

@ -14,7 +14,7 @@
.span-24.last
%h3
New Today
Yesterday's results
- [:posts, :comments, :aspect_memberships, :users].each do |name|
- model = eval("@#{name.to_s}")
@ -23,11 +23,10 @@
.span-6{:class => ('last' if name == :users)}
%h2{:style => 'font-weight:bold;'}
= model[:today]
= model[:yesterday]
= name.to_s
%h4
= model[:yesterday]
= model[:day_before]
%span.percent_change{:class => (model[:change] > 0 ? "green" : "red")}
= "(#{model[:change]}%)"