[Bps-public-commit] r15084 - in sd/trunk: .

spang at bestpractical.com spang at bestpractical.com
Tue Aug 12 09:32:35 EDT 2008


Author: spang
Date: Tue Aug 12 09:32:31 2008
New Revision: 15084

Modified:
   sd/trunk/   (props changed)
   sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm

Log:
 r47782 at loki:  spang | 2008-08-06 00:51:59 +0100
 simplify ticket details command code by using comment / attachment references


Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Details.pm	Tue Aug 12 09:32:31 2008
@@ -2,6 +2,8 @@
 use Moose;
 extends 'App::SD::CLI::Command::Ticket::Show';
 
+sub by_creation_date { $a->prop('created') cmp $b->prop('created') };
+
 override run => sub {
     my $self = shift;
     my $record = $self->_load_record;
@@ -10,25 +12,12 @@
     super();
 
     print "\n=head1 ATTACHMENTS\n\n";
-    my $attachments = App::SD::Collection::Attachment->new(
-        handle => $self->app_handle->handle,
-        app_handle => $self->app_handle,
-    );
-    $attachments->matching(sub {
-        shift->prop('ticket') eq $self->uuid ? 1 : 0;
-    });
-    print $_->format_summary . "\n" for $attachments->items;
+    my @attachments = sort by_creation_date @{$record->attachments};
+    print $_->format_summary . "\n" for @attachments;
 
     print "\n=head1 COMMENTS\n\n";
-    my $comments = App::SD::Collection::Comment->new(
-        handle => $self->app_handle->handle,
-    );
-    $comments->matching(sub {
-        shift->prop('ticket') eq $self->uuid ? 1 : 0;
-    });
-    my @items = sort { $a->prop('created') cmp $b->prop('created') }
-                    $comments->items;
-    print $_->prop('created') . "\n" . $_->prop('content') . "\n\n" for @items;
+    my @comments = sort by_creation_date @{$record->comments};
+    print $_->prop('created') . "\n" . $_->prop('content') . "\n\n" for @comments;
 };
 
 __PACKAGE__->meta->make_immutable;



More information about the Bps-public-commit mailing list