[Bps-public-commit] r19881 - in Net-Google-Code/trunk/lib/Net/Google/Code: Issue

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Jun 4 00:11:55 EDT 2009


Author: sunnavy
Date: Thu Jun  4 00:11:54 2009
New Revision: 19881

Modified:
   Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Search.pm
   Net-Google-Code/trunk/lib/Net/Google/Code/Role/Pageable.pm

Log:
remove modified_after arg for search, it is too ambigous to be useful

Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Search.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Search.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Search.pm	Thu Jun  4 00:11:54 2009
@@ -8,8 +8,6 @@
 with  'Net::Google::Code::Role::HTMLTree';
 use Net::Google::Code::Issue;
 use Encode;
-use Date::Manip;
-local $ENV{TZ} = 'GMT';
 
 our %CAN_MAP = (
     'all'    => 1,
@@ -37,7 +35,6 @@
         load_after_search => 1,
         can               => 2,
         colspec           => 'ID+Type+Status+Priority+Milestone+Owner+Summary',
-        modified_after     => undef,
         @_
     );
 
@@ -45,26 +42,15 @@
         $args{can} = $CAN_MAP{ $args{can} };
     }
 
-    if ( $args{modified_after} ) {
-        $args{colspec} .= '+Modified' unless $args{colspec} =~ /Modified/;
-
-        # convert modified_after to epoch
-        if ( ref $args{modified_after} ) {
-            $args{modified_after} = $args{modified_after}->epoch;
-        }
-        else {
-            $args{modified_after} = UnixDate( $args{modified_after}, '%o' );
-        }
-    }
-
+    my @results;
 
     my $mech = $self->mech;
-    my $url = $self->base_url . 'issues/list?';
+    my $url  = $self->base_url . 'issues/list?';
     for my $type (qw/can q sort colspec/) {
         next unless defined $args{$type};
         $url .= $type . '=' . $args{$type} . '&';
     }
-    $self->fetch( $url );
+    $self->fetch($url);
 
     die "Server threw an error " . $mech->response->status_line . 'when search'
       unless $mech->response->is_success;
@@ -74,10 +60,11 @@
     if ( $mech->title =~ /issue\s+(\d+)/i ) {
 
         # get only one ticket
-        my $issue =
-          Net::Google::Code::Issue->new( project => $self->project, id => $1, );
-        $issue->load if $args{load_after_search};
-        $self->results( [$issue] );
+        my $issue = Net::Google::Code::Issue->new(
+            project => $self->project,
+            id      => $1,
+        );
+        @results = $issue;
     }
     elsif ( $mech->title =~ /issues/i ) {
 
@@ -85,24 +72,25 @@
         my @rows = $self->rows(
             html           => $content,
             limit          => $args{limit},
-            modified_after => $args{modified_after},
         );
 
-        my @issues;
         for my $row (@rows) {
-            my $issue = Net::Google::Code::Issue->new(
+            push @results,
+              Net::Google::Code::Issue->new(
                 project => $self->project,
                 %$row,
-            );
-            $issue->load if $args{load_after_search};
-            push @issues, $issue;
+              );
         }
-        $self->results( \@issues );
     }
     else {
         warn "no idea what the content like";
         return;
     }
+
+    if ( $args{load_after_search} ) {
+        $_->load for @results;
+    }
+    $self->results( \@results );
 }
 
 no Any::Moose;
@@ -122,7 +110,7 @@
 
 =over 4
 
-=item search ( can => 'all', q = 'foo', sort => '-modified', limit => 1000 )
+=item search ( can => 'all', q = 'foo', sort => '-modified', limit => 1000, load_after_search => 1 )
 
 do the search, the results is set to $self->results,
   which is an arrayref with Net::Google::Code::Issue as element.
@@ -136,12 +124,6 @@
 load_after_search => Bool is to state if we should call $issue->load after
 search
 
-modified_after => DateTime
-CAVEAT: this usually doesn't do what you want, be careful.
-In fact, it just filter issues by comparing the arg and the Modified column
-value, of which the date is not only rough, but also is just about the
-properity change: new comments without prop changes won't affect this value.
-
 return true if search is successful, false on the other hand.
 
 =item project

Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Role/Pageable.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Role/Pageable.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Role/Pageable.pm	Thu Jun  4 00:11:54 2009
@@ -5,10 +5,6 @@
 with 'Net::Google::Code::Role::Fetchable';
 with 'Net::Google::Code::Role::HTMLTree';
 use Scalar::Util qw/blessed/;
-use Date::Manip;
-use DateTime;
-local $ENV{TZ} = 'GMT';
-
 
 sub rows {
     my $self = shift;
@@ -20,10 +16,6 @@
                 type     => SCALAR | UNDEF,
                 optional => 1,
             },
-            modified_after => {
-                type => SCALAR | OBJECT | UNDEF,
-                optional => 1,
-            },
         }
     );
 
@@ -31,8 +23,6 @@
     my $tree = $args{html};
     $tree = $self->html_tree( html => $tree ) unless blessed $tree;
 
-    my $modified_after = $args{modified_after};
-
     # assuming there's at most 20 columns
     my @titles;
     my $label_column;
@@ -66,20 +56,8 @@
     return unless $pagination;
 
     if ( $pagination->as_text =~ /\d+\s+-\s+\d+\s+of\s+\d+/ ) {
-        my $filter = sub {
-            return 1 unless $args{modified_after};
-            my $row = shift;
-            if ( $row->{modified} ) {
-                my $epoch = UnixDate( $row->{modified}, '%o' );
-                if ( $epoch >= $args{modified_after} ) {
-                    return 1;
-                }
-            }
-            return;
-        };
-
         # all the rows in a page
-        push @rows, grep { $filter->($_) } $self->_rows(
+        push @rows, $self->_rows(
             html         => $tree,
             titles       => \@titles,
             label_column => $label_column,
@@ -90,7 +68,7 @@
             if ($next_link) {
                 $self->mech->get( $next_link->url );
                 if ( $self->mech->response->is_success ) {
-                    push @rows, grep { $filter->($_) } $self->_rows(
+                    push @rows, $self->_rows(
                         html         => $self->mech->content,
                         titles       => \@titles,
                         label_column => $label_column,



More information about the Bps-public-commit mailing list