Group project-related stats into a class.

Reduce number of instance variables available to the views.
Replace raw SQL with AR-type query.
This commit is contained in:
Katrina Owen 2013-03-02 17:11:19 -07:00
parent 1e3782ce67
commit 8b1f0a34a0
4 changed files with 27 additions and 21 deletions

View file

@ -0,0 +1,22 @@
module Stats
class Projects
attr_reader :user
def initialize(user)
@user = user
end
def runtime
@runtime ||= user.projects.active.order('created_at ASC').limit(10)
end
def actions
@actions ||= Stats::TopProjectsQuery.new(user).result
end
def actions_last30days
@actions_last30days ||= Stats::TopProjectsQuery.new(user, 1.month.ago.beginning_of_day).result
end
end
end