diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index 27a8cb95..198bfc14 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -34,11 +34,21 @@ class TodoController < ApplicationController # Use days declaration? 1.day.ago? def completed @page_title = "TRACKS::Completed tasks" - today_query = "DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= completed" - week_query = "DATE_SUB(CURDATE(),INTERVAL 2 DAY) >= completed - AND DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= completed" - month_query = "DATE_SUB(CURDATE(),INTERVAL 8 DAY) >= completed - AND DATE_SUB(CURDATE(),INTERVAL 31 DAY) <= completed" + today_date = Date::today() - 1 + today_query = today_date.strftime("'%Y-%m-%d'") + " <= completed" + + week_begin = Date::today() - 2 + week_end = Date::today() - 7 + + week_query = week_begin.strftime("'%Y-%m-%d'") + " >= completed + AND " + week_end.strftime("'%Y-%m-%d'") + " <= completed" + + month_begin = Date::today() - 8 + month_end = Date::today() - 31 + + month_query = month_begin.strftime("'%Y-%m-%d'") + " >= completed + AND " + month_end.strftime("'%Y-%m-%d'") + " <= completed" + @done_today = Todo.find_by_sql( "SELECT * FROM todos WHERE done = 1 AND #{today_query} ORDER BY completed DESC;" ) @done_this_week = Todo.find_by_sql( "SELECT * FROM todos WHERE done = 1 AND #{week_query} @@ -51,7 +61,8 @@ class TodoController < ApplicationController # def completed_archive @page_title = "TRACKS::Archived completed tasks" - archive_query = "DATE_SUB(CURDATE(),INTERVAL 32 DAY) >= completed" + archive_date = Date::today() - 32 + archive_query = archive_date.strftime("'%Y-%m-%d'") + " >= completed" @done_archive = Todo.find_by_sql( "SELECT * FROM todos WHERE done = 1 AND #{archive_query} ORDER BY completed DESC;" ) end diff --git a/tracks/app/views/todo/_done.rhtml b/tracks/app/views/todo/_done.rhtml new file mode 100644 index 00000000..d5d1de14 --- /dev/null +++ b/tracks/app/views/todo/_done.rhtml @@ -0,0 +1,25 @@ +<% @done_item = done %> + +<% if @done_item.completed %> + <%= image_tag( "done", :width=>"16", :height=>"16", :border=>"0") %> + <%= format_date( @done_item.completed ) %> + <%= " " + @done_item.description + " "%> + + <% if @done_item.project_id %> + <%= "(" + @done_item.context['name'] + ", " + @done_item.project['name'] + ")" %> + <% else %> + <%= "(" + @done_item.context['name'] + ")" %> + <% end %> + + <% if @done_item.due %> + <%= " - was due on " + format_date( @done_item.due ) %> + <% end %> + + <% if @done_item.notes? %> + <%= "" + image_tag( "notes", :width=>"10", :height=>"10", :border=>"0") + "" %> + <% m_notes = markdown( @done_item.notes ) %> + <%= "
" + m_notes + "
" %> + <% end %> + +<% end %> + \ No newline at end of file