mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-27 01:24:07 +01:00
Group context-related pieces in a class
This commit is contained in:
parent
8b1f0a34a0
commit
6ccb9a81fb
5 changed files with 35 additions and 19 deletions
27
app/models/stats/contexts.rb
Normal file
27
app/models/stats/contexts.rb
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
module Stats
|
||||
class Contexts
|
||||
|
||||
attr_reader :user
|
||||
def initialize(user)
|
||||
@user = user
|
||||
end
|
||||
|
||||
def actions
|
||||
@actions ||= Stats::TopContextsQuery.new(user, :limit => 5).result
|
||||
end
|
||||
|
||||
def running_actions
|
||||
@running_actions ||= Stats::TopContextsQuery.new(user, :limit => 5, :running => true).result
|
||||
end
|
||||
|
||||
def charts
|
||||
@charts = %w{
|
||||
context_total_actions_data
|
||||
context_running_actions_data
|
||||
}.map do |action|
|
||||
Stats::Chart.new(action, :height => 325)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
# Get action count for the top 5 contexts
|
||||
# If initialized with :running, then only active
|
||||
# Get action count for the top n contexts (default: all)
|
||||
# If initialized with :running => true, then only active
|
||||
# and visible contexts will be included.
|
||||
module Stats
|
||||
class TopContextsQuery
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue