mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-18 00:00:12 +01:00
Encapsulate dependencies of stats index page
This may be a bit extreme. It's modeled after the ideal "rails way". In the controller, we now know the name of a single resource. It doesn't happen to be backed by a database table, but it does know all about the task of collecting stats, leaving the controller concerned with just munging params and rendering stuff. I called the resource `IndexPage`, to avoid the temptation of trying to reuse it, which can get pretty messy. Later, if a better abstraction appears, it should be fairly painless to alter.
This commit is contained in:
parent
6df3534baf
commit
d5a555fbac
3 changed files with 50 additions and 15 deletions
|
|
@ -8,15 +8,7 @@ class StatsController < ApplicationController
|
|||
def index
|
||||
@page_title = t('stats.index_title')
|
||||
@hidden_contexts = current_user.contexts.hidden
|
||||
@actions = Stats::Actions.new(current_user)
|
||||
@totals = Stats::Totals.new(current_user)
|
||||
@projects = Stats::Projects.new(current_user)
|
||||
@contexts = Stats::Contexts.new(current_user)
|
||||
tags = Stats::TagCloudQuery.new(current_user).result
|
||||
@tag_cloud = Stats::TagCloud.new(tags)
|
||||
cutoff = 3.months.ago.beginning_of_day
|
||||
tags = Stats::TagCloudQuery.new(current_user, cutoff).result
|
||||
@tag_cloud_90days = Stats::TagCloud.new(tags)
|
||||
@stats = Stats::IndexPage.new(current_user)
|
||||
end
|
||||
|
||||
def actions_done_last12months_data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue