Class: Stats::Totals

Inherits:
Object
  • Object
show all
Defined in:
app/models/stats/totals.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#userObject (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

#actionsObject (private)



75
76
77
# File 'app/models/stats/totals.rb', line 75

def actions
  user.todos
end

#active_projectsObject



29
30
31
# File 'app/models/stats/totals.rb', line 29

def active_projects
  user.projects.active.count
end

#all_actionsObject



53
54
55
# File 'app/models/stats/totals.rb', line 53

def all_actions
  actions.count
end

#blocked_actionsObject



69
70
71
# File 'app/models/stats/totals.rb', line 69

def blocked_actions
  actions.blocked.count
end

#completed_actionsObject



57
58
59
# File 'app/models/stats/totals.rb', line 57

def completed_actions
  actions.completed.count
end

#completed_projectsObject



37
38
39
# File 'app/models/stats/totals.rb', line 37

def completed_projects
  user.projects.completed.count
end

#contextsObject



41
42
43
# File 'app/models/stats/totals.rb', line 41

def contexts
  user.contexts.count
end

#deferred_actionsObject



65
66
67
# File 'app/models/stats/totals.rb', line 65

def deferred_actions
  actions.deferred.count
end

#empty?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/models/stats/totals.rb', line 9

def empty?
  actions.empty?
end

#first_actionObject (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_atObject



21
22
23
# File 'app/models/stats/totals.rb', line 21

def first_action_at
  first_action.try(:created_at)
end

#hidden_contextsObject



49
50
51
# File 'app/models/stats/totals.rb', line 49

def hidden_contexts
  user.contexts.hidden.count
end

#hidden_projectsObject



33
34
35
# File 'app/models/stats/totals.rb', line 33

def hidden_projects
  user.projects.hidden.count
end

#incomplete_actionsObject



61
62
63
# File 'app/models/stats/totals.rb', line 61

def incomplete_actions
  actions.not_completed.count
end

#projectsObject



25
26
27
# File 'app/models/stats/totals.rb', line 25

def projects
  user.projects.count
end

#tag_idsObject (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

#tagsObject



13
14
15
# File 'app/models/stats/totals.rb', line 13

def tags
  @tags ||= tag_ids.size
end

#unique_tagsObject



17
18
19
# File 'app/models/stats/totals.rb', line 17

def unique_tags
  @unique_tags ||= tag_ids.uniq.size
end

#visible_contextsObject



45
46
47
# File 'app/models/stats/totals.rb', line 45

def visible_contexts
  user.contexts.active.count
end