• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

The details for this issue are discussed at TWiki:Codev.SearchByCreateDate.

A first patch is attached to that topic too. ATM it is not well tested but deployed on my site. smile

Missing are patched to the TWiki User documentation, but this is rather easy. If I get green light, then I can write it too, of course.

Ok, here is the patch:

--- lib/TWiki/Search.pm.orig   2006-03-31 13:53:54.000000000 +0200
+++ lib/TWiki/Search.pm   2006-03-31 17:27:15.000000000 +0200
@@ -401,6 +401,7 @@
     my $type =          $params{type} || '';
     my $webName =       $params{web} || '';
     my $date =          $params{date} || '';
+    my $createdate =    $params{createdate} || '';
     my $recurse =       $params{'recurse'} || '';
     my $finalTerm =     $inline ? ( $params{nofinalnewline} || 0 ) : 0;
 
@@ -665,15 +666,35 @@
             }
         }
 
-        if( $date ){
+        if( $date || $createdate ) {
             use TWiki::Time;
-            my @ends = &TWiki::Time::parseInterval( $date );
+            my @ends = ();
             my @resultList = ();
-            foreach my $topic ( @topicList ) {
-                # if date falls out of interval: exclude topic from result
-                my $topicdate = $store->getTopicLatestRevTime( $web, $topic );
-                push( @resultList, $topic )
-                  unless ( $topicdate < $ends[0] || $topicdate > $ends[1] );
+
+            # Design Decision: although the inner foreach loop is mostly common for 
+            #   date and createdate, we do not share it because deciding if we look
+            #   for createdate or last modifieddate in each loop is more expensive
+            #   and weights more than 3-4 lines of code duplication.
+            # If given both params (date and createdate) we prefer createdate.
+            if( $createdate ) {
+                # the createdate = date of the first revision
+                @ends = &TWiki::Time::parseInterval( $createdate );
+                foreach my $topic ( @topicList ) {
+                    # if date falls out of interval: exclude topic from result
+                    my $r1info = {};
+                    my $topicdate = $this->_getRev1Info( $web, $topic, 'unformatteddate', $r1info );
+                    push( @resultList, $topic )
+                        unless ( $topicdate < $ends[0] || $topicdate > $ends[1] );
+                }
+            } else {
+                # the date = date of the last (actual) revision
+                @ends = &TWiki::Time::parseInterval( $date );
+                foreach my $topic ( @topicList ) {
+                    # if date falls out of interval: exclude topic from result
+                    my $topicdate = $store->getTopicLatestRevTime( $web, $topic );
+                    push( @resultList, $topic )
+                       unless ( $topicdate < $ends[0] || $topicdate > $ends[1] );
+                }
             }
             @topicList = @resultList;
         }
@@ -1078,7 +1099,8 @@
 
 # Returns the topic revision info of the base version,
 # attributes are 'date', 'username', 'wikiname',
-# 'wikiusername'. Revision info is cached in the search
+# 'wikiusername' and 'unformatteddate'. 
+# Revision info is cached in the search
 # object for speed.
 sub _getRev1Info {
     my( $this, $web, $topic, $attr, $info ) = @_;
@@ -1104,6 +1126,9 @@
     if( $attr eq 'date' ) {
         return TWiki::Time::formatTime( $info->{date} );
     }
+    if( $attr eq 'unformatteddate' ) {
+        return $info->{date};
+    }
 
     return 1;
 }


thanks tobias! i've applied this patch to the DEVELOP branch. please let me know when the docs are updated and we can mark this as "Waiting for Release" (for 4.1) some unit tests (http://develop.twiki.org/svn/twiki/branches/DEVELOP/test/unit/) would be nice, too wink

WN


Ok, I added the specific entry to TWiki:TWiki.VarSEARCH.

Off topic: While doing this, I recognized, that TWiki:TWiki.TWikiVariables looked somewhat older than TWiki:TWiki04.TWikiVariables. Indeed, even the date option was missing for SEARCH as that page included the older TWikiSearch page instead of the newer VarSEARCH page. Do I missunderstand something or is this a know problem/bug?

-- TWiki:Main.TobiasRoeser - 22 Apr 2006


if you're referring to the docs on twiki.org, the TWiki web is for the version of twiki that's installed on twiki.org (currently still cairo). best to modify your local version and submit a patch that i can check into svn.

thanks for working on this! it is a welcome addition smile

WN


Ok, here is the (simple) patch:

--- data/TWiki/VarSEARCH.txt.orig   2006-04-22 22:34:29.000000000 +0200
+++ data/TWiki/VarSEARCH.txt   2006-04-22 22:47:17.000000000 +0200
@@ -17,6 +17,7 @@
      | =order="topic"= <br /> =order="created"= <br />  =order="modified"= <br /> =order="editby"= <br /> =order=<br />&nbsp;"formfield(name)"= | Sort the results of search by the topic names, topic creation time, last modified time, last editor, or named field of TWikiForms. The sorting is done web by web; if you want to sort across webs, create a [[FormattedSearch][formatted]] table and sort it with TablePlugin's initsort. Note that dates are sorted most recent date *last* (i.e at the bottom of the table). | Sort by topic name |
      | =limit="all"= <br /> =limit="16"= | Limit the number of results returned. This is done after sorting if =order= is specified | All results |
      | =date="..."= | limits the results to those pages with latest edit time in the given TimeInterval.  | All results |
+     | =createdate="..."= | Limits the results to those pages with latest create time (time of the first page revision) in the given TimeInterval. If this option *and* the =date= option are used, the =date= option will be ignored.  | All results |
      | =reverse="on"= | Reverse the direction of the search | Ascending search |
      | =casesensitive="on"= | Case sensitive search | Ignore case |
      | =bookview="on"= | BookView search, e.g. show complete topic text | Show topic summary |

I reverted my changed to TWiki:TWiki web, too.

-- TWiki:Main.TobiasRoeser - 22 Apr 2006

4.1.0 released

KJL

ItemTemplate
Summary Add search by createdate option to SEARCH
ReportedBy TWiki:Main.TobiasRoeser
Codebase

SVN Range Mon, 27 Mar 2006 build 9563
AppliesTo Engine
Component

Priority Enhancement
CurrentState Closed
WaitingFor

Checkins 9849 9890
TargetRelease minor
Edit | Attach | Watch | Print version | History: r17 < r16 < r15 < r14 < r13 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r17 - 2007-01-16 - KennethLavrsen
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback