Encapsulate counts and totals into a class.

Move queries out of the view and into the model layer.
This commit is contained in:
Katrina Owen 2013-03-02 17:22:15 -07:00
parent 6ccb9a81fb
commit 615a9e46c9
4 changed files with 106 additions and 22 deletions

View file

@ -7,13 +7,9 @@ class StatsController < ApplicationController
def index
@page_title = t('stats.index_title')
@first_action = current_user.todos.reorder("created_at ASC").first
tag_ids = Stats::UserTagsQuery.new(current_user).result.map(&:id)
@tags_count = tag_ids.size
@unique_tags_count = tag_ids.uniq.size
@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)