tracks/app/models/stats/projects.rb
Katrina Owen 8b1f0a34a0 Group project-related stats into a class.
Reduce number of instance variables available to the views.
Replace raw SQL with AR-type query.
2013-03-02 17:12:14 -07:00

22 lines
437 B
Ruby

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