Commit c0d882a2 authored by Leo Gordon's avatar Leo Gordon
Browse files

Protect generate_graph.pl in job-drawing mode from printing too many jobs (by...

Protect generate_graph.pl in job-drawing mode from printing too many jobs (by setting a limit in JSON config)
parent 5215a997
......@@ -68,7 +68,7 @@
},
"DisplayStats" : "barchart", # show analysis statistics using "barchart", "text" or "" (don't show statistics)
"DisplayJobs" : 0,
"DisplayJobs" : 0, # if nonzero, represents the max number of jobs to show in each analysis node
"DisplayData" : 0,
"DisplayDetails" : 1,
......
......@@ -309,9 +309,15 @@ sub _add_analysis_node {
}
}
if( $self->config_get('DisplayJobs') ) {
if( my $job_limit = $self->config_get('DisplayJobs') ) {
my $adaptor = $self->dba->get_AnalysisJobAdaptor();
my @jobs = sort {$a->dbID <=> $b->dbID} @{ $adaptor->fetch_all_by_analysis_id_status( $analysis->dbID )};
my @jobs = sort {$a->dbID <=> $b->dbID} @{ $adaptor->fetch_some_by_analysis_id_limit( $analysis->dbID, $job_limit+1 )};
my $hit_limit;
if(scalar(@jobs)>$job_limit) {
pop @jobs;
$hit_limit = 1;
}
$analysis_label .= '<tr><td colspan="'.$colspan.'"> </td></tr>';
foreach my $job (@jobs) {
......@@ -323,6 +329,10 @@ sub _add_analysis_node {
$input_id=~s/\{|\}//g;
$analysis_label .= qq{<tr><td colspan="$colspan" bgcolor="}.$self->config_get('Node', 'JobStatus', $status, 'Colour').qq{">$job_id [$status]: $input_id</td></tr>};
}
if($hit_limit) {
$analysis_label .= qq{<tr><td colspan="$colspan">[ and }.($total_job_count-$job_limit).qq{ more ]</td></tr>};
}
}
$analysis_label .= '</table>>';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment