[Bps-public-commit] rt-extension-jsgantt branch, master, updated. 5a61e8b4e9346b251578e18398d0eee35ed4daa0

? sunnavy sunnavy at bestpractical.com
Thu Jul 8 11:38:10 EDT 2010


The branch, master has been updated
       via  5a61e8b4e9346b251578e18398d0eee35ed4daa0 (commit)
      from  0d7037d01c029fc2ac7879c6976a3f12e8a9fafa (commit)

Summary of changes:
 lib/RT/Extension/JSGantt.pm |   58 ++++++++++++++++++++++++++-----------------
 1 files changed, 35 insertions(+), 23 deletions(-)

- Log -----------------------------------------------------------------
commit 5a61e8b4e9346b251578e18398d0eee35ed4daa0
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Jul 8 22:49:12 2010 +0800

    refactor tickets order: not perfect yet

diff --git a/lib/RT/Extension/JSGantt.pm b/lib/RT/Extension/JSGantt.pm
index b106a95..b76240b 100644
--- a/lib/RT/Extension/JSGantt.pm
+++ b/lib/RT/Extension/JSGantt.pm
@@ -35,29 +35,7 @@ sub AllRelatedTickets {
             }
         }
 
-        while ( my $ticket = shift @to_be_checked ) {
-            push @tickets, $ticket
-              unless grep { $ticket->id eq $_->id } @tickets;
-            push @to_be_checked,
-              grep { !$checked{ $_->id }++ }
-              _RelatedTickets( $ticket, 'Members' );
-        }
-
-        @to_be_checked = @tickets;
-        while ( my $ticket = shift @to_be_checked ) {
-            push @tickets, $ticket
-              unless grep { $ticket->id eq $_->id } @tickets;
-            unshift @to_be_checked,
-              grep { !$checked{ $_->id }++ }
-              _RelatedTickets( $ticket, 'Members' );
-            unshift @to_be_checked,
-              grep { !$checked{ $_->id }++ }
-              _RelatedTickets( $ticket, 'MemberOf' );
-            push @to_be_checked, grep { !$checked{ $_->id }++ } _RelatedTickets(
-                $ticket, 'DependsOn', 'DependedOnBy', 'RefersTo',
-                'ReferredToBy'
-            );
-        }
+        _GetOrderedTickets( \@tickets, \@to_be_checked, \%checked );
     }
     return @tickets;
 }
@@ -265,6 +243,40 @@ sub _GetDate {
 }
 
 
+sub _GetOrderedTickets {
+    my $tickets       = shift;
+    my $to_be_checked = shift;
+    my $checked       = shift;
+    while ( my $ticket = shift @$to_be_checked ) {
+        push @$tickets, $ticket
+          unless grep { $ticket->id eq $_->id } @$tickets;
+        next if $checked->{$ticket->id}++;
+
+        for my $member ( grep { !$checked->{ $_->id } }
+            _RelatedTickets( $ticket, 'Members' ) )
+        {
+            unshift @$to_be_checked, $member;
+            _GetOrderedTickets( $tickets,$to_be_checked, $checked );
+        }
+
+        for my $parent ( grep { !$checked->{ $_->id } }
+            _RelatedTickets( $ticket, 'MemberOf' ) )
+        {
+            unshift @$to_be_checked, $parent;
+            _GetOrderedTickets( $tickets, $to_be_checked, $checked );
+        }
+
+        for my $related ( grep { !$checked->{ $_->id } }
+            _RelatedTickets( $ticket, 'DependsOn', 'DependedOnBy', 'RefersTo',
+            'ReferredToBy' ))
+        {
+            push @$to_be_checked, $related;
+            _GetOrderedTickets( $tickets, $to_be_checked, $checked );
+        }
+    }
+}
+
+
 =head1 NAME
 
 RT::Extension::JSGantt - 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list