From 743d8d55b645cb64b4202402db84d653d26db306 Mon Sep 17 00:00:00 2001 From: Leo Gordon <lg4@ebi.ac.uk> Date: Tue, 23 Sep 2014 19:19:15 +0100 Subject: [PATCH] API change : AJA::fetch_all_by_analysis_id_status now takes an optional $list_of_analyses argument --- .../Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm | 16 ++++++++++++---- scripts/beekeeper.pl | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm b/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm index b751244f8..7b34d1073 100644 --- a/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm +++ b/modules/Bio/EnsEMBL/Hive/DBSQL/AnalysisJobAdaptor.pm @@ -138,21 +138,29 @@ sub store_jobs_and_adjust_counters { =head2 fetch_all_by_analysis_id_status - Arg [1] : (optional) int $analysis_id + Arg [1] : (optional) listref $list_of_analyses Arg [2] : (optional) string $status Arg [3] : (optional) int $retry_at_least Example : $all_failed_jobs = $adaptor->fetch_all_by_analysis_id_status(undef, 'FAILED'); - $analysis_done_jobs = $adaptor->fetch_all_by_analysis_id_status($analysis->dbID, 'DONE'); + $analysis_done_jobs = $adaptor->fetch_all_by_analysis_id_status( $list_of_analyses, 'DONE'); Description: Returns a list of all jobs filtered by given analysis_id (if specified) and given status (if specified). Returntype : reference to list of Bio::EnsEMBL::Hive::AnalysisJob objects =cut sub fetch_all_by_analysis_id_status { - my ($self, $analysis_id, $status, $retry_count_at_least) = @_; + my ($self, $list_of_analyses, $status, $retry_count_at_least) = @_; my @constraints = (); - push @constraints, "analysis_id=$analysis_id" if ($analysis_id); + + if($list_of_analyses) { + if(ref($list_of_analyses) eq 'ARRAY') { + push @constraints, "analysis_id IN (".(join(',', map {$_->dbID} @$list_of_analyses)).")"; + } else { + push @constraints, "analysis_id=$list_of_analyses"; # for compatibility with old interface + } + } + push @constraints, "status='$status'" if ($status); push @constraints, "retry_count >= $retry_count_at_least" if ($retry_count_at_least); diff --git a/scripts/beekeeper.pl b/scripts/beekeeper.pl index 4acb87d79..328f52e46 100755 --- a/scripts/beekeeper.pl +++ b/scripts/beekeeper.pl @@ -275,7 +275,7 @@ sub main { if($show_failed_jobs) { print("===== failed jobs\n"); - my $failed_job_list = $self->{'dba'}->get_AnalysisJobAdaptor->fetch_all_by_analysis_id_status($analysis && $analysis->dbID, 'FAILED'); + my $failed_job_list = $self->{'dba'}->get_AnalysisJobAdaptor->fetch_all_by_analysis_id_status( $self->{'logic_name'} and $list_of_analyses , 'FAILED'); foreach my $job (@{$failed_job_list}) { print $job->toString. "\n"; -- GitLab