[Rt-commit] r5863 - in rt/branches/3.7-EXPERIMENTAL: . lib/RT/Shredder/Plugin/Base

ruz at bestpractical.com ruz at bestpractical.com
Tue Sep 5 12:59:04 EDT 2006


Author: ruz
Date: Tue Sep  5 12:59:03 2006
New Revision: 5863

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder/Plugin/Base/Search.pm
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder/Plugin/Users.pm

Log:
 r3700 at cubic-pc:  cubic | 2006-09-05 20:55:55 +0400
 * move FetchNext method into RT::Shredder::Plugin::Base::Search


Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder/Plugin/Base/Search.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder/Plugin/Base/Search.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder/Plugin/Base/Search.pm	Tue Sep  5 12:59:03 2006
@@ -21,6 +21,8 @@
 
 Allow you to limit search results. B<< Default value is C<10> >>.
 
+=head1 METHODS
+
 =cut
 
 sub SupportArgs
@@ -51,5 +53,42 @@
 
 sub SetResolvers { return 1 }
 
+
+=head2 FetchNext $collection [, $init]
+
+Returns next object in collection as method L<RT::SearchBuilder/Next>, but
+doesn't stop on page boundaries.
+
+When method is called with true C<$init> arg it enables pages on collection
+and selects first page.
+
+Main purpose of this method is to avoid loading of whole collection into
+memory as RT does by default when pager is not used. This method init paging
+on the collection, but doesn't stop when reach page end.
+
+Example:
+
+    $plugin->FetchNext( $tickets, 'init' );
+    while( my $ticket = $plugin->FetchNext( $tickets ) ) {
+        ...
+    }
+
+=cut
+
+use constant PAGE_SIZE => 100;
+sub FetchNext {
+    my ($self, $objs, $init) = @_;
+    if ( $init ) {
+        $objs->RowsPerPage( PAGE_SIZE );
+        $objs->FirstPage;
+        return;
+    }
+
+    my $obj = $objs->Next;
+    return $obj if $obj;
+    $objs->NextPage;
+    return $objs->Next;
+}
+
 1;
 

Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder/Plugin/Users.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder/Plugin/Users.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder/Plugin/Users.pm	Tue Sep  5 12:59:03 2006
@@ -155,23 +155,6 @@
     return (1);
 }
 
-use constant PAGE_SIZE => 100;
-
-sub FetchNext {
-    my ($self, $objs, $init) = @_;
-    if ( $init ) {
-        $objs->RowsPerPage( PAGE_SIZE );
-        $objs->FirstPage;
-        return;
-    }
-
-    for (1..3) {
-        my $obj = $objs->Next;
-        return $obj if $obj;
-        $objs->NextPage;
-    }
-}
-
 sub FilterWithoutTickets {
     my $self = shift;
     my %args = (


More information about the Rt-commit mailing list