Class: Stats::Totals
- Inherits:
-
Object
- Object
- Stats::Totals
- Defined in:
- app/models/stats/totals.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #actions ⇒ Object private
- #active_projects ⇒ Object
- #all_actions ⇒ Object
- #blocked_actions ⇒ Object
- #completed_actions ⇒ Object
- #completed_projects ⇒ Object
- #contexts ⇒ Object
- #deferred_actions ⇒ Object
- #empty? ⇒ Boolean
- #first_action ⇒ Object private
- #first_action_at ⇒ Object
- #hidden_contexts ⇒ Object
- #hidden_projects ⇒ Object
- #incomplete_actions ⇒ Object
-
#initialize(user) ⇒ Totals
constructor
A new instance of Totals.
- #projects ⇒ Object
- #tag_ids ⇒ Object private
- #tags ⇒ Object
- #unique_tags ⇒ Object
- #visible_contexts ⇒ Object
Constructor Details
#initialize(user) ⇒ Totals
Returns a new instance of Totals.
5 6 7 |
# File 'app/models/stats/totals.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/totals.rb', line 3 def user @user end |
Instance Method Details
#actions ⇒ Object (private)
75 76 77 |
# File 'app/models/stats/totals.rb', line 75 def actions user.todos end |
#active_projects ⇒ Object
29 30 31 |
# File 'app/models/stats/totals.rb', line 29 def active_projects user.projects.active.count end |
#all_actions ⇒ Object
53 54 55 |
# File 'app/models/stats/totals.rb', line 53 def all_actions actions.count end |
#blocked_actions ⇒ Object
69 70 71 |
# File 'app/models/stats/totals.rb', line 69 def blocked_actions actions.blocked.count end |
#completed_actions ⇒ Object
57 58 59 |
# File 'app/models/stats/totals.rb', line 57 def completed_actions actions.completed.count end |
#completed_projects ⇒ Object
37 38 39 |
# File 'app/models/stats/totals.rb', line 37 def completed_projects user.projects.completed.count end |
#contexts ⇒ Object
41 42 43 |
# File 'app/models/stats/totals.rb', line 41 def contexts user.contexts.count end |
#deferred_actions ⇒ Object
65 66 67 |
# File 'app/models/stats/totals.rb', line 65 def deferred_actions actions.deferred.count end |
#empty? ⇒ Boolean
9 10 11 |
# File 'app/models/stats/totals.rb', line 9 def empty? actions.empty? end |
#first_action ⇒ Object (private)
79 80 81 |
# File 'app/models/stats/totals.rb', line 79 def first_action @first_action ||= user.todos.reorder("created_at ASC").first end |
#first_action_at ⇒ Object
21 22 23 |
# File 'app/models/stats/totals.rb', line 21 def first_action_at first_action.try(:created_at) end |
#hidden_contexts ⇒ Object
49 50 51 |
# File 'app/models/stats/totals.rb', line 49 def hidden_contexts user.contexts.hidden.count end |
#hidden_projects ⇒ Object
33 34 35 |
# File 'app/models/stats/totals.rb', line 33 def hidden_projects user.projects.hidden.count end |
#incomplete_actions ⇒ Object
61 62 63 |
# File 'app/models/stats/totals.rb', line 61 def incomplete_actions actions.not_completed.count end |
#projects ⇒ Object
25 26 27 |
# File 'app/models/stats/totals.rb', line 25 def projects user.projects.count end |
#tag_ids ⇒ Object (private)
83 84 85 |
# File 'app/models/stats/totals.rb', line 83 def tag_ids @tag_ids ||= Stats::UserTagsQuery.new(user).result.map(&:id) end |
#tags ⇒ Object
13 14 15 |
# File 'app/models/stats/totals.rb', line 13 def @tags ||= tag_ids.size end |
#unique_tags ⇒ Object
17 18 19 |
# File 'app/models/stats/totals.rb', line 17 def @unique_tags ||= tag_ids.uniq.size end |
#visible_contexts ⇒ Object
45 46 47 |
# File 'app/models/stats/totals.rb', line 45 def visible_contexts user.contexts.active.count end |