Patch assumed to be against AT version 11698
Enhancements to improve the actionnotify operation:
- Generate the keys in sorted order so they don't re-order themselves randomly.
- Allow actionnotify be able to specify the "age=X" parameter
- Allow actionnotify be able to specify the "duedays=X" parameter
Example usage in a crontab:
#
# TWiki Action Tracker Notification Support
#
# - Late AI, get notified 3 times per week, on Mon, Wed, and Fri
# - AI due in 3 days, get notified once per day
# - AI due in 7 days, get notified once per day
# - When an AI gets created, get notified on that day
#
21 23 * * 1,3,5 (cd /var/www/twiki/tools; perl -I ../bin ./actionnotify state=late)
22 01 * * * (cd /var/www/twiki/tools; perl -I ../bin ./actionnotify state=open duedays=3)
23 01 * * * (cd /var/www/twiki/tools; perl -I ../bin ./actionnotify state=open duedays=7)
24 23 * * * (cd /var/www/twiki/tools; perl -I ../bin ./actionnotify state=open age=0)
25 23 * * * (cd /var/www/twiki/tools; perl -I ../bin ./actionnotify changedsince=yesterday)
--- lib/TWiki/Plugins/ActionTrackerPlugin/Action.pm 2007/01/10 17:00:08 1.1
+++ lib/TWiki/Plugins/ActionTrackerPlugin/Action.pm 2007/01/10 17:06:01
@@ -117,6 +117,10 @@
new TWiki::Plugins::ActionTrackerPlugin::AttrDef( 'names', $nw, 1, 0, undef ),
within =>
new TWiki::Plugins::ActionTrackerPlugin::AttrDef( 'noload', 0, 1, 0, undef ),
+ duedays =>
+ new TWiki::Plugins::ActionTrackerPlugin::AttrDef( 'noload', 0, 1, 0, undef ),
+ age =>
+ new TWiki::Plugins::ActionTrackerPlugin::AttrDef( 'noload', 0, 1, 0, undef ),
ACTION_NUMBER=>
new TWiki::Plugins::ActionTrackerPlugin::AttrDef( 'noload', 0, 0, 0, undef ),
);
@@ -329,7 +333,7 @@
my $this = shift;
my $attrs = '';
my $descr = '';
- foreach my $key ( keys %$this ) {
+ foreach my $key ( sort ( keys %$this ) ) {
my $type = $types{$key};
if ( $key eq 'text') {
$descr = $this->{text};
@@ -439,6 +443,15 @@
}
}
+# PUBLIC return how many days old the action item is.
+sub daysOld {
+ my $this = shift;
+ if ( defined ($this->{created} )) {
+ return ($now - $this->{created}) / 86400;
+ }
+ return -1;
+}
+
# PUBLIC true if due time is before now and not closed
sub isLate {
my $this = shift;
@@ -495,6 +508,28 @@
}
}
+# PRIVATE match if there are at exactly $val duedays to go before
+# action falls due
+sub _matchField_duedays {
+ my ( $this, $val ) = @_;
+ my $slack = $this->secsToGo() - $val * 86400;
+ if ($val > 0) {
+ return ($slack <= 0) && ($slack >= -86400);
+ } else {
+ return ($slack >= 0) && ($slack <= 86400);
+ }
+}
+
+# PRIVATE match if the action item's age is exactly $val days ago
+sub _matchField_age {
+ my ( $this, $val ) = @_;
+ if ($val >= 0) {
+ return ($this->daysOld() - $val) == 0;
+ } else {
+ return 0;
+ }
+}
+
# PRIVATE match boolean attribute "closed"
sub _matchField_closed {
my ( $this, $val ) = @_;
--
TWiki:Main.JonDiekema - 10 Jan 2007
Nice one, thanks Jon. Before I can apply the patch I need you to:
- Verify that the patch is against rev 11698
- Provide user documentation
- Update the unit testcases so that the functionality of the patch is tested and the existing tests don't fail when this patch is applied.
- If you can't work out how to do this I will help, but it would be most helpful if you could do 1 and 2
Thanks,
CC
Jon mailed me:
I didn't realize that I had this out there. I will work to complete items 1 and 2, since it would be desirable to get this into the mainline.
Changed state to "Being worked on"
CC
The sort change of the patch is already in the source:
- foreach my $key ( keys %$this ) {
+ foreach my $key ( sort ( keys %$this ) ) {
The "age" and "duedays" parameters introduced by the patch may either have been subsumed by the "due=" parameter or we simply didn't understand the "due=" parameter when we invented the new parameters.
It looks to me like the example crontab entries:
22 01 * * * (cd /var/www/twiki/tools; perl -I ../bin ./actionnotify state=open duedays=3)
23 01 * * * (cd /var/www/twiki/tools; perl -I ../bin ./actionnotify state=open duedays=7)
24 23 * * * (cd /var/www/twiki/tools; perl -I ../bin ./actionnotify state=open age=0)
can be expressed as:
22 01 * * * (cd /var/www/twiki/tools; perl -I ../bin ./actionnotify state=open due="now + 3 days")
23 01 * * * (cd /var/www/twiki/tools; perl -I ../bin ./actionnotify state=open due="now + 7 days")
24 23 * * * (cd /var/www/twiki/tools; perl -I ../bin ./actionnotify state=open due="now")
I have not had time to confirm this, however.
--
JerryVanBaren - 16 Apr 2007
No further feedback for a year. Closed.
--
CrawfordCurrie - 13 Apr 2008