mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-24 19:20:13 +01:00
Reduce number of instance variables available to the views. Replace raw SQL with AR-type query.
22 lines
437 B
Ruby
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
|