From 5778e7276d7289f9dacaa221178aca5614ff6b6f Mon Sep 17 00:00:00 2001
From: Leo Gordon <lg4@ebi.ac.uk>
Date: Thu, 8 Nov 2012 10:50:51 +0000
Subject: [PATCH] job_count_breakout now also returns the components that go
 into the breakout_label

---
 modules/Bio/EnsEMBL/Hive/AnalysisStats.pm | 14 ++++++++------
 modules/Bio/EnsEMBL/Hive/Utils/Graph.pm   |  4 +++-
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/modules/Bio/EnsEMBL/Hive/AnalysisStats.pm b/modules/Bio/EnsEMBL/Hive/AnalysisStats.pm
index 88dee2516..3eca41bae 100644
--- a/modules/Bio/EnsEMBL/Hive/AnalysisStats.pm
+++ b/modules/Bio/EnsEMBL/Hive/AnalysisStats.pm
@@ -274,16 +274,18 @@ sub inprogress_job_count {
 sub job_count_breakout {
     my $self = shift;
 
-    my @counter_list = ();
+    my @count_list = ();
+    my %count_hash = ();
+    my $total_job_count = $self->total_job_count();
     foreach my $count_method (qw(semaphored_job_count ready_job_count inprogress_job_count done_job_count failed_job_count)) {
-        if(my $count = $self->$count_method()) {
-            push @counter_list, $count.substr($count_method,0,1);
+        if( my $count = $count_hash{$count_method} = $self->$count_method() ) {
+            push @count_list, $count.substr($count_method,0,1);
         }
     }
-    my $breakout = join('+', @counter_list);
-    $breakout .= '='.$self->total_job_count() if(scalar(@counter_list)!=1); # only provide a total if multiple or no categories available
+    my $breakout_label = join('+', @count_list);
+    $breakout_label .= '='.$total_job_count if(scalar(@count_list)!=1); # only provide a total if multiple or no categories available
 
-    return $breakout;
+    return ($breakout_label, $total_job_count, \%count_hash);
 }
 
 
diff --git a/modules/Bio/EnsEMBL/Hive/Utils/Graph.pm b/modules/Bio/EnsEMBL/Hive/Utils/Graph.pm
index 1bda0189b..bd151769d 100644
--- a/modules/Bio/EnsEMBL/Hive/Utils/Graph.pm
+++ b/modules/Bio/EnsEMBL/Hive/Utils/Graph.pm
@@ -275,8 +275,10 @@ sub _add_analysis_node {
   my ($self, $a) = @_;
 
   my $stats = $a->stats();
+
+  my ($breakout_label) = $stats->job_count_breakout();
   
-  my $analysis_label    = $a->logic_name().' ('.$a->dbID().')\n'.$stats->job_count_breakout();
+  my $analysis_label    = $a->logic_name().' ('.$a->dbID().')\n'.$breakout_label;
   my $shape             = $a->can_be_empty() ? 'doubleoctagon' : 'ellipse' ;
   my $status_colour     = $self->config->get('Graph', 'Node', $stats->status, 'Colour');
   my $node_fontname     = $self->config->get('Graph', 'Node', $stats->status, 'Font');
-- 
GitLab