[Bps-public-commit] r17531 - in Net-Trac/trunk: . t
trs at bestpractical.com
trs at bestpractical.com
Fri Jan 2 14:45:51 EST 2009
Author: trs
Date: Fri Jan 2 14:45:51 2009
New Revision: 17531
Modified:
Net-Trac/trunk/ (props changed)
Net-Trac/trunk/lib/Net/Trac/Ticket.pm
Net-Trac/trunk/lib/Net/Trac/TicketSearch.pm
Net-Trac/trunk/t/02-create.t
Log:
r43405 at zot: tom | 2009-01-02 14:45:38 -0500
Load tickets from search results CSV since we can grab more data from it in one shot
Modified: Net-Trac/trunk/lib/Net/Trac/Ticket.pm
==============================================================================
--- Net-Trac/trunk/lib/Net/Trac/Ticket.pm (original)
+++ Net-Trac/trunk/lib/Net/Trac/Ticket.pm Fri Jan 2 14:45:51 2009
@@ -3,6 +3,7 @@
use Params::Validate qw(:all);
use Lingua::EN::Inflect qw();
+use Net::Trac::TicketSearch;
use Net::Trac::TicketHistory;
use Net::Trac::TicketAttachment;
@@ -49,13 +50,14 @@
sub load {
my $self = shift;
my ($id) = validate_pos( @_, { type => SCALAR } );
- $self->connection->_fetch( "/ticket/" . $id . "?format=csv" ) or return;
- my $content = $self->connection->mech->content;
- my $stateref = $self->connection->_csv_to_struct( data => \$content, key => 'id' );
- return undef unless $stateref;
+ my $search = Net::Trac::TicketSearch->new( connection => $self->connection );
+ $search->limit(1);
+ $search->query( id => $id, _no_objects => 1 );
- my $tid = $self->load_from_hashref( $stateref->{$id} );
+ return unless @{ $search->results };
+
+ my $tid = $self->load_from_hashref( $search->results->[0] );
return $tid;
}
Modified: Net-Trac/trunk/lib/Net/Trac/TicketSearch.pm
==============================================================================
--- Net-Trac/trunk/lib/Net/Trac/TicketSearch.pm (original)
+++ Net-Trac/trunk/lib/Net/Trac/TicketSearch.pm Fri Jan 2 14:45:51 2009
@@ -16,6 +16,8 @@
my $self = shift;
my %query = @_;
+ my $no_objects = delete $query{'_no_objects'};
+
# Clear current results
$self->results([]);
@@ -29,14 +31,18 @@
my $data = $self->connection->_csv_to_struct( data => \$content, key => 'id', type => 'array' );
- my @tickets = ();
- for ( @{$data || []} ) {
- my $ticket = Net::Trac::Ticket->new( connection => $self->connection );
- my $id = $ticket->load_from_hashref( $_ );
- push @tickets, $ticket if $id;
+ unless ( $no_objects ) {
+ my @tickets = ();
+ for ( @{$data || []} ) {
+ my $ticket = Net::Trac::Ticket->new( connection => $self->connection );
+ my $id = $ticket->load_from_hashref( $_ );
+ push @tickets, $ticket if $id;
+ }
+ return $self->results( \@tickets );
+ }
+ else {
+ return $self->results( $data );
}
-
- return $self->results( \@tickets );
}
__PACKAGE__->meta->make_immutable;
Modified: Net-Trac/trunk/t/02-create.t
==============================================================================
--- Net-Trac/trunk/t/02-create.t (original)
+++ Net-Trac/trunk/t/02-create.t Fri Jan 2 14:45:51 2009
@@ -31,3 +31,5 @@
like($ticket->state->{'summary'}, qr/pony/);
like($ticket->summary, qr/pony/, "The summary looks like a pony");
ok($ticket->history, "The ticket has some history");
+ok($ticket->time, "The ticket has a created time: ".$ticket->time);
+
More information about the Bps-public-commit
mailing list