Class: Stats::Projects

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#userObject (readonly)

Returns the value of attribute user


4
5
6
# File 'app/models/stats/projects.rb', line 4

def user
  @user
end

Instance Method Details

#actionsObject


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

def actions
  @actions ||= Stats::TopProjectsQuery.new(user).result
end

#actions_last30daysObject


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_projectsObject (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{|a,b| b.running_time <=> a.running_time}.take(10)
end

#runtimeObject


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

def runtime
  @runtime ||= find_top10_longest_running_projects
end