mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-30 20:55:17 +01:00
Fixes #243.
The 'done' page was generating errors (a regression in the trunk since the tagging of 1.04). I think that the main problem was the code to find the done items, but while I was at it I simplified the completed() and completed_archive() methods by using the Rails Time::Calculation methods x.day.ago and x.week.ago. Works OK for me now. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@213 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
a716eb8aef
commit
9723645dcd
3 changed files with 13 additions and 20 deletions
|
|
@ -5,6 +5,7 @@ require_dependency "login_system"
|
|||
require_dependency "redcloth"
|
||||
|
||||
require 'date'
|
||||
require 'Time'
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
|
||||
|
|
|
|||
|
|
@ -165,34 +165,26 @@ class TodoController < ApplicationController
|
|||
end
|
||||
|
||||
# List the completed tasks, sorted by completion date
|
||||
#
|
||||
# Use days declaration? 1.day.ago?
|
||||
# @done_today: in the last 24 hours
|
||||
# @done_this_week: in the last week
|
||||
# @done_this_month: in the last 4 weeks (<=28 days)
|
||||
def completed
|
||||
self.init
|
||||
@page_title = "TRACKS::Completed tasks"
|
||||
|
||||
day = (60 * 60 * 24)
|
||||
today = Time.now
|
||||
|
||||
today_date = today - (1 * day)
|
||||
week_begin = today - (1 * day)
|
||||
week_end = today - (7 * day)
|
||||
month_begin = today - (8 * day)
|
||||
month_end = today - (31 * day)
|
||||
|
||||
@done_today = @done.collect { |x| today_date <= x.completed ? x:nil }.compact
|
||||
@done_this_week = @done.collect { |x| week_begin >= x.completed && week_end <= x.completed ? x:nil }.compact
|
||||
@done_this_month = @done.collect { |x| month_begin >= x.completed && month_end <= x.completed ? x:nil }.compact
|
||||
|
||||
unless @done.nil?
|
||||
@done_today = @done.collect { |x| x.completed >= 1.day.ago ? x:nil }.compact
|
||||
@done_this_week = @done.collect { |x| 1.week.ago <= x.completed ? x:nil }.compact
|
||||
@done_this_month = @done.collect { |x| 4.week.ago <= x.completed ? x:nil }.compact
|
||||
end
|
||||
end
|
||||
|
||||
# Archived completed items, older than 31 days
|
||||
# Archived completed items, older than 28 days
|
||||
#
|
||||
def completed_archive
|
||||
self.init
|
||||
@page_title = "TRACKS::Archived completed tasks"
|
||||
archive_date = Time.now - 32 * (60 * 60 * 24)
|
||||
@done_archive = @done.collect { |x| archive_date >= x.completed ? x:nil }.compact
|
||||
@done_archive = @done.collect { |x| 28.day.ago > x.completed ? x:nil }.compact
|
||||
end
|
||||
|
||||
def feeds
|
||||
|
|
@ -218,7 +210,7 @@ class TodoController < ApplicationController
|
|||
@projects = @user.projects
|
||||
@contexts = @user.contexts
|
||||
@todos = @user.todos
|
||||
@done = @todos.find_all { |x| x.done }
|
||||
@done = @todos.find(:all, :conditions => ["done = ?", true])
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<div id="display_box_projects">
|
||||
<p>You have completed <%= @done_today.length %> actions so far today.</p>
|
||||
<div class="container">
|
||||
<h2>Completed today</h2>
|
||||
<h2>Completed in the last 24 hours</h2>
|
||||
<table class="next_actions" cellspacing="5" cellpadding="0" border="0">
|
||||
<%= render :partial => "done", :collection => @done_today %>
|
||||
</table>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue