mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-07 05:10:19 +01:00
Fix issue where completed items would redundantly show context on a context page and project on a project page.
Eliminated some N+1 query generation issues on context and project detail pages related to looking up tags. Added rake task to turn on and off the mysql query_analyzer plugin, which I'm using to help in my optimization process. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@662 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
1516d7ae14
commit
0f823a8a2e
9 changed files with 55 additions and 16 deletions
|
|
@ -155,12 +155,14 @@ class ContextsController < ApplicationController
|
|||
def init_todos
|
||||
set_context_from_params
|
||||
unless @context.nil?
|
||||
@done = @context.done_todos
|
||||
@context.todos.with_scope :find => { :include => [:project, :tags] } do
|
||||
@done = @context.done_todos
|
||||
end
|
||||
# @not_done_todos = @context.not_done_todos
|
||||
# TODO: Temporarily doing this search manually until I can work out a way
|
||||
# to do the same thing using not_done_todos acts_as_todo_container method
|
||||
# Hides actions in hidden projects from context.
|
||||
@not_done_todos = @context.todos.find(:all, :conditions => ['todos.state = ?', 'active'], :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC", :include => :project)
|
||||
@not_done_todos = @context.todos.find(:all, :conditions => ['todos.state = ?', 'active'], :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC", :include => [:project, :tags])
|
||||
@count = @not_done_todos.size
|
||||
@default_project_context_name_map = build_default_project_context_name_map(@projects).to_json
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,9 +27,11 @@ class ProjectsController < ApplicationController
|
|||
def show
|
||||
init_data_for_sidebar
|
||||
@page_title = "TRACKS::Project: #{@project.name}"
|
||||
@not_done = @project.not_done_todos(:include_project_hidden_todos => true)
|
||||
@deferred = @project.deferred_todos.sort_by { |todo| todo.show_from }
|
||||
@done = @project.done_todos
|
||||
@project.todos.with_scope :find => { :include => [:context, :tags] } do
|
||||
@not_done = @project.not_done_todos(:include_project_hidden_todos => true)
|
||||
@deferred = @project.deferred_todos.sort_by { |todo| todo.show_from }
|
||||
@done = @project.done_todos
|
||||
end
|
||||
@count = @not_done.size
|
||||
@next_project = current_user.projects.next_from(@project)
|
||||
@previous_project = current_user.projects.previous_from(@project)
|
||||
|
|
|
|||
|
|
@ -93,19 +93,23 @@ module TodosHelper
|
|||
end
|
||||
end
|
||||
|
||||
def project_and_context_links(parent_container_type)
|
||||
def project_and_context_links(parent_container_type, opts = {})
|
||||
str = ''
|
||||
if @todo.completed?
|
||||
"(#{@todo.context.name}#{", " + @todo.project.name unless @todo.project.nil?})"
|
||||
str += @todo.context.name unless opts[:suppress_context]
|
||||
should_suppress_project = opts[:suppress_project] || @todo.project.nil?
|
||||
str += ", " unless str.blank? || should_suppress_project
|
||||
str += @todo.project.name unless should_suppress_project
|
||||
str = "(#{str})" unless str.blank?
|
||||
else
|
||||
str = ''
|
||||
if (['project', 'tag'].include?(parent_container_type))
|
||||
str << item_link_to_context( @todo )
|
||||
end
|
||||
if (['context', 'tickler', 'tag'].include?(parent_container_type)) && @todo.project_id
|
||||
str << item_link_to_project( @todo )
|
||||
end
|
||||
str
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
# Uses the 'staleness_starts' value from settings.yml (in days) to colour the
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<div id="display_box">
|
||||
<%= render :partial => "contexts/context", :locals => { :context => @context, :collapsible => false } %>
|
||||
<%= render :partial => "todos/completed", :locals => { :done => @done, :collapsible => false, :append_descriptor => "in this context (last #{prefs.show_number_completed})" } %>
|
||||
<%= render :partial => "todos/completed", :locals => { :done => @done, :suppress_context => true, :collapsible => false, :append_descriptor => "in this context (last #{prefs.show_number_completed})" } %>
|
||||
|
||||
</div><!-- [end:display_box] -->
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<%= render :partial => "projects/project", :locals => { :project => @project, :collapsible => false } %>
|
||||
<%= render :partial => "todos/deferred", :locals => { :deferred => @deferred, :collapsible => false, :append_descriptor => "in this project" } %>
|
||||
<%= render :partial => "todos/completed", :locals => { :done => @done, :collapsible => false, :append_descriptor => "in this project" } %>
|
||||
<%= render :partial => "todos/completed", :locals => { :done => @done, :collapsible => false, :suppress_project => true, :append_descriptor => "in this project" } %>
|
||||
|
||||
<div class="container">
|
||||
<div id="notes">
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
<% suffix = append_descriptor ? append_descriptor : '' -%>
|
||||
<% suffix = append_descriptor ? append_descriptor : ''
|
||||
suppress_context ||= false
|
||||
suppress_project ||= false
|
||||
-%>
|
||||
<div class="container completed" id="completed_container">
|
||||
<h2>
|
||||
<% if collapsible %>
|
||||
<a href="#" class="container_toggle" id="toggle_completed"><%= image_tag("collapse.png") %></a>
|
||||
<% end %>
|
||||
Completed actions <%= append_descriptor ? append_descriptor : '' %>
|
||||
Completed actions <%= suffix %>
|
||||
</h2>
|
||||
<div id="completed" class="items toggle_target">
|
||||
|
||||
|
|
@ -12,6 +15,6 @@
|
|||
<div class="message"><p>Currently there are no completed actions.</p></div>
|
||||
</div>
|
||||
|
||||
<%= render :partial => "todos/todo", :collection => done, :locals => { :parent_container_type => "completed" } %>
|
||||
<%= render :partial => "todos/todo", :collection => done, :locals => { :parent_container_type => "completed", :suppress_context => suppress_context, :suppress_project => suppress_project } %>
|
||||
</div>
|
||||
</div><!-- [end:next_actions] -->
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
<%
|
||||
@todo = todo
|
||||
suppress_context ||= false
|
||||
suppress_project ||= false
|
||||
%>
|
||||
<div id="<%= dom_id(todo) %>" class="item-container">
|
||||
<div id="<%= dom_id(todo, 'line') %>">
|
||||
|
|
@ -12,7 +14,7 @@
|
|||
<%= sanitize(todo.description) %>
|
||||
<%= tag_list %>
|
||||
<%= deferred_due_date %>
|
||||
<%= project_and_context_links( parent_container_type ) %>
|
||||
<%= project_and_context_links( parent_container_type, :suppress_context => suppress_context, :suppress_project => suppress_project ) %>
|
||||
<%= render(:partial => "todos/toggle_notes", :locals => { :item => todo }) if todo.notes? %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue