[Bps-public-commit] r14834 - in sd: trunk/lib/App/SD/CLI/Command/Ticket trunk/lib/App/SD/CLI/Command/Ticket/Attachment trunk/lib/App/SD/CLI/Command/Ticket/Comment

spang at bestpractical.com spang at bestpractical.com
Tue Aug 5 20:15:45 EDT 2008


Author: spang
Date: Tue Aug  5 20:15:06 2008
New Revision: 14834

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

Log:
 r47749 at loki:  spang | 2008-08-06 00:21:16 +0100
 simplify the details command code by using attachment/comment references instead of searching through all the attachment/comment records
 r47781 at loki:  spang | 2008-08-06 00:49:33 +0100
 undo that last commit
 r47782 at loki:  spang | 2008-08-06 00:51:59 +0100
 simplify ticket details command code by using comment / attachment references
 r47783 at loki:  spang | 2008-08-06 00:58:13 +0100
 make commands that require uuids and don't inherit from prophet commands that also do fail more gracefully when uuid is not set
 r47784 at loki:  spang | 2008-08-06 01:13:02 +0100
 fix an omission, yay for tests


Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm	Tue Aug  5 20:15:06 2008
@@ -5,6 +5,8 @@
 
 before run => sub {
     my $self = shift;
+    $self->require_uuid;
+
     $self->set_prop(ticket => $self->cli->uuid);
 };
 

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm	Tue Aug  5 20:15:06 2008
@@ -8,6 +8,7 @@
 # override args to feed in that ticket's uuid as an argument to the comment
 before run => sub {
     my $self = shift;
+    $self->require_uuid;
 
     my $content = $self->get_content(type => 'comment', default_edit => 1);
 

Modified: sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm
==============================================================================
--- sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm	(original)
+++ sd/trunk/lib/App/SD/CLI/Command/Ticket/Comments.pm	Tue Aug  5 20:15:06 2008
@@ -7,12 +7,14 @@
 sub run {
     my $self = shift;
     my $record = $self->_get_record_class();
+
+    $self->require_uuid;
     $record->load( uuid => $self->uuid );
     unless (@{$record->comments}) {
         print "No comments found\n";
     }
 
-    for my $entry (sort { $a->prop('date') cmp $b->prop('date') } @{$record->comments}) {
+    for my $entry (sort { $a->prop('created') cmp $b->prop('created') } @{$record->comments}) {
          print "id: ".$entry->luid." (".$entry->uuid.")\n";
         print "created: ".$entry->prop('created')."\n";
         print $entry->prop('content')."\n";

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  5 20:15:06 2008
@@ -2,33 +2,24 @@
 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;
+
+    $self->require_uuid;
     my $record = $self->_load_record;
 
     print "\n=head1 METADATA\n\n";
     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