Class: Stats::Projects
- Inherits:
-
Object
- Object
- Stats::Projects
- Defined in:
- app/models/stats/projects.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #actions ⇒ Object
- #actions_last30days ⇒ Object
- #find_top10_longest_running_projects ⇒ Object private
-
#initialize(user) ⇒ Projects
constructor
A new instance of Projects.
- #runtime ⇒ Object
Constructor Details
#initialize(user) ⇒ Projects
Returns a new instance of Projects.
5 6 7 |
# File 'app/models/stats/projects.rb', line 5 def initialize(user) @user = user end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'app/models/stats/projects.rb', line 3 def user @user end |
Instance Method Details
#actions ⇒ Object
13 14 15 |
# File 'app/models/stats/projects.rb', line 13 def actions @actions ||= Stats::TopProjectsQuery.new(user).result end |
#actions_last30days ⇒ Object
17 18 19 |
# File 'app/models/stats/projects.rb', line 17 def actions_last30days @actions_last30days ||= Stats::TopProjectsQuery.new(user, 1.month.ago.beginning_of_day).result end |
#find_top10_longest_running_projects ⇒ Object (private)
23 24 25 26 |
# File 'app/models/stats/projects.rb', line 23 def find_top10_longest_running_projects projects = user.projects.order('created_at ASC') projects.sort_by { |p| p.running_time }.reverse.take(10) end |
#runtime ⇒ Object
9 10 11 |
# File 'app/models/stats/projects.rb', line 9 def runtime @runtime ||= find_top10_longest_running_projects end |