From 1c736a319d8a3a6aa8a7524bd8895d7dc1f0185c Mon Sep 17 00:00:00 2001
From: Paul Beckingham
Date: Sat, 9 May 2009 22:32:40 -0400
Subject: [PATCH] Enhancement - Custom report limit override
- If a custom report has a specified limit to the number of tasks
it shows, then that limit may be overridden by specifying a new
quantity on the command line.
- Added unit tests to verify expected behavior.
- Updated documentation to reflect new functionality.
- Removed obsolete documentation references to an "oldest" and
"newest" configuration variable.
---
ChangeLog | 3 ++
html/advanced.html | 20 +++++++++----
html/task.html | 3 ++
src/report.cpp | 10 +++++++
src/task.cpp | 2 +-
src/tests/oldest.t | 70 +++++++++++++++++++++++++++++++---------------
6 files changed, 79 insertions(+), 29 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 14c2a8dec..a0e170610 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,9 @@
+ Fixed bug that added an extra line between header and graph in the
ghistory report.
+ Added simple 'taskprogram' mailing list subscribe form to the web site.
+ + For custom reports that define a "limit" to the number of rows of output
+ such as "oldest" and "newest", task allows an override value. For
+ example "task oldest 5" will display the 5 oldest tasks.
------ old releases ------------------------------
diff --git a/html/advanced.html b/html/advanced.html
index e132aee78..976dcd2d6 100644
--- a/html/advanced.html
+++ b/html/advanced.html
@@ -294,16 +294,24 @@ ID Project Pri Description
12 Errand L Remember to deposit bonus check
...
- % task oldest
+ % task oldest [limit]
- Lists the oldest tasks. Shows 10 tasks by default, but can be
- set via the "oldest" configuration variable.
+ Lists the oldest tasks. The number of tasks shown is set by
+ the configuration variable:
+
report.oldest.limit=10
+ This value can be overridden at run time by specifying the
+ number of tasks on the command line:
+ task oldest 5
-
- Lists the newest tasks. Shows 10 tasks by default, but can be
- set via the "newest" configuration variable.
+ Lists the newest tasks. The number of tasks shown is set by
+ the configuration variable:
+
For custom reports that define a "limit" to the number of rows of output
+ such as "oldest" and "newest", task allows an override value. For
+ example "task oldest 5" will display the 5 oldest tasks.
diff --git a/src/report.cpp b/src/report.cpp
index ba42bd27b..bb22a904d 100644
--- a/src/report.cpp
+++ b/src/report.cpp
@@ -2521,8 +2521,18 @@ std::string handleCustomReport (
}
}
+ // Limit the number of rows according to the report definition.
int maximum = conf.get (std::string ("report.") + report + ".limit", (int)0);
+ // If the custom report has a defined limit, then allow an override, which
+ // will show up as a single ID sequence.
+ if (conf.get (std::string ("report.") + report + ".limit", (int)0) != 0)
+ {
+ std::vector sequence = task.getAllIds ();
+ if (sequence.size () == 1)
+ maximum = sequence[0];
+ }
+
std::stringstream out;
if (table.rowCount ())
out << optionalBlankLine (conf)
diff --git a/src/task.cpp b/src/task.cpp
index a16a7f1f1..92c34ed4b 100644
--- a/src/task.cpp
+++ b/src/task.cpp
@@ -133,7 +133,7 @@ static std::string shortUsage (Config& conf)
table.addCell (row, 2, "Removes the 'start' time from a task");
row = table.addRow ();
- table.addCell (row, 1, "task done ID");
+ table.addCell (row, 1, "task done ID [tags] [attrs] [desc...]");
table.addCell (row, 2, "Marks the specified task as completed");
row = table.addRow ();
diff --git a/src/tests/oldest.t b/src/tests/oldest.t
index f3aae2d02..7149db7d2 100755
--- a/src/tests/oldest.t
+++ b/src/tests/oldest.t
@@ -28,7 +28,7 @@
use strict;
use warnings;
-use Test::More tests => 33;
+use Test::More tests => 55;
# Create the rc file.
if (open my $fh, '>', 'oldest.rc')
@@ -66,30 +66,56 @@ qx{../task rc:oldest.rc add ten; sleep 1};
qx{../task rc:oldest.rc add eleven};
$output = qx{../task rc:oldest.rc oldest};
-like ($output, qr/one/, 'oldest: one');
-like ($output, qr/two/, 'oldest: two');
-like ($output, qr/three/, 'oldest: three');
-like ($output, qr/four/, 'oldest: four');
-like ($output, qr/five/, 'oldest: five');
-like ($output, qr/six/, 'oldest: six');
-like ($output, qr/seven/, 'oldest: seven');
-like ($output, qr/eight/, 'oldest: eight');
-like ($output, qr/nine/, 'oldest: nine');
-like ($output, qr/ten/, 'oldest: ten');
+like ($output, qr/one/, 'oldest: one');
+like ($output, qr/two/, 'oldest: two');
+like ($output, qr/three/, 'oldest: three');
+like ($output, qr/four/, 'oldest: four');
+like ($output, qr/five/, 'oldest: five');
+like ($output, qr/six/, 'oldest: six');
+like ($output, qr/seven/, 'oldest: seven');
+like ($output, qr/eight/, 'oldest: eight');
+like ($output, qr/nine/, 'oldest: nine');
+like ($output, qr/ten/, 'oldest: ten');
+unlike ($output, qr/eleven/, 'no: eleven');
+
+$output = qx{../task rc:oldest.rc oldest 3};
+like ($output, qr/one/, 'oldest: one');
+like ($output, qr/two/, 'oldest: two');
+like ($output, qr/three/, 'oldest: three');
+unlike ($output, qr/four/, 'no: four');
+unlike ($output, qr/five/, 'no: five');
+unlike ($output, qr/six/, 'no: six');
+unlike ($output, qr/seven/, 'no: seven');
+unlike ($output, qr/eight/, 'no: eight');
+unlike ($output, qr/nine/, 'no: nine');
+unlike ($output, qr/ten/, 'no: ten');
unlike ($output, qr/eleven/, 'no: eleven');
$output = qx{../task rc:oldest.rc newest};
-unlike ($output, qr/one/, 'no: one');
-like ($output, qr/two/, 'newest: two');
-like ($output, qr/three/, 'newest: three');
-like ($output, qr/four/, 'newest: four');
-like ($output, qr/five/, 'newest: five');
-like ($output, qr/six/, 'newest: six');
-like ($output, qr/seven/, 'newest: seven');
-like ($output, qr/eight/, 'newest: eight');
-like ($output, qr/nine/, 'newest: nine');
-like ($output, qr/ten/, 'newest: ten');
-like ($output, qr/eleven/, 'newest: eleven');
+unlike ($output, qr/one/, 'no: one');
+like ($output, qr/two/, 'newest: two');
+like ($output, qr/three/, 'newest: three');
+like ($output, qr/four/, 'newest: four');
+like ($output, qr/five/, 'newest: five');
+like ($output, qr/six/, 'newest: six');
+like ($output, qr/seven/, 'newest: seven');
+like ($output, qr/eight/, 'newest: eight');
+like ($output, qr/nine/, 'newest: nine');
+like ($output, qr/ten/, 'newest: ten');
+like ($output, qr/eleven/, 'newest: eleven');
+
+$output = qx{../task rc:oldest.rc newest 3};
+unlike ($output, qr/one/, 'no: one');
+unlike ($output, qr/two/, 'no: two');
+unlike ($output, qr/three/, 'no: three');
+unlike ($output, qr/four/, 'no: four');
+unlike ($output, qr/five/, 'no: five');
+unlike ($output, qr/six/, 'no: six');
+unlike ($output, qr/seven/, 'no: seven');
+unlike ($output, qr/eight/, 'no: eight');
+like ($output, qr/nine/, 'newest: nine');
+like ($output, qr/ten/, 'newest: ten');
+like ($output, qr/eleven/, 'newest: eleven');
# Cleanup.
unlink 'pending.data';