From 9d5503a91e638664c0412389e771b6e34c8cf52b Mon Sep 17 00:00:00 2001
From: Reinier Balt
Date: Sat, 1 May 2010 17:19:28 +0200
Subject: [PATCH] fix #997. The chart with the visible actions now excludes
pending actions. Also some cleanupt to use named_scope
---
app/controllers/stats_controller.rb | 3 ++-
app/models/todo.rb | 3 +++
app/views/stats/_totals.rhtml | 22 ++++++++++++----------
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb
index 3847c47a..004b335c 100755
--- a/app/controllers/stats_controller.rb
+++ b/app/controllers/stats_controller.rb
@@ -319,6 +319,7 @@ class StatsController < ApplicationController
# - actions not part of a hidden project
# - actions not part of a hidden context
# - actions not deferred (show_from must be null)
+ # - actions not pending/blocked
@actions_running_time = @actions.find_by_sql([
"SELECT t.created_at "+
@@ -326,7 +327,7 @@ class StatsController < ApplicationController
"WHERE t.user_id=? "+
"AND t.completed_at IS NULL " +
"AND t.show_from IS NULL " +
- "AND NOT (p.state='hidden' OR c.hide=?) " +
+ "AND NOT (p.state='hidden' OR p.state='pending' OR c.hide=?) " +
"ORDER BY t.created_at ASC", @user.id, true]
)
diff --git a/app/models/todo.rb b/app/models/todo.rb
index 7fd64628..e4c60712 100644
--- a/app/models/todo.rb
+++ b/app/models/todo.rb
@@ -18,7 +18,10 @@ class Todo < ActiveRecord::Base
named_scope :active, :conditions => { :state => 'active' }
named_scope :not_completed, :conditions => ['NOT (todos.state = ? )', 'completed']
+ named_scope :completed, :conditions => ["NOT completed_at IS NULL"]
named_scope :are_due, :conditions => ['NOT (todos.due IS NULL)']
+ named_scope :deferred, :conditions => ["completed_at IS NULL AND NOT show_from IS NULL"]
+ named_scope :blocked, :conditions => ['todos.state = ?', 'pending']
STARRED_TAG_NAME = "starred"
RE_TODO = /[^"]+/
diff --git a/app/views/stats/_totals.rhtml b/app/views/stats/_totals.rhtml
index 02e2301d..500fde10 100755
--- a/app/views/stats/_totals.rhtml
+++ b/app/views/stats/_totals.rhtml
@@ -1,19 +1,21 @@
You have <%= @projects.count%> projects.
- Of those <%= @projects.count(:conditions => "state = 'active'")%> are active projects,
- <%= @projects.count(:conditions => "state = 'hidden'")%> hidden projects and
-<%= @projects.count(:conditions => "state = 'completed'")%> completed projects
+ Of those <%= @projects.active.count%> are active projects,
+ <%= @projects.hidden.count%> hidden projects and
+<%= @projects.completed.count%> completed projects
You have <%= @contexts.count%> contexts.
-Of those <%= @contexts.count(:conditions => ["hide = ?", false])%> are visible contexts and
-<%= @contexts.count(:conditions => ["hide = ?", true]) %> are hidden contexts
+Of those <%= @contexts.active.count%> are visible contexts and
+<%= @contexts.hidden.count%> are hidden contexts
<% unless @actions.empty? -%>
-
You have <%= @actions.count(:conditions => "completed_at IS NULL") %> incomplete actions
-of which <%= @actions.count(:conditions => "completed_at IS NULL AND NOT show_from IS NULL") %> are deferred actions.
+Since your first action on <%= format_date(@first_action.created_at) %>
+you have a total of <%= @actions.count %> actions.
+<%= @actions.completed.count %> of these are completed.
-
Since your first action on <%= format_date(@first_action.created_at) %>
-you have a total of <%= @actions.count %> actions.
-<%= @actions.count(:conditions => "NOT completed_at IS NULL") %> of these are completed.
+
You have <%= @actions.not_completed.count %> incomplete actions
+of which <%= @actions.deferred.count %> are deferred actions
+in the tickler and <%= @actions.blocked.count %> are dependent on the completion of other actions.
+.
You have <%= @tags_count-%> tags placed on actions. Of those tags,
<%= @unique_tags_count -%> are unique.