Commit 687358d8 authored by Jessica Severin's avatar Jessica Severin
Browse files

refactored the logic for update_analysis_stats so that it updates the stats

on all anlyses, not just the ones with entries in the analysis_job table.
New logic is also faster.
parent 44b38e8a
......@@ -197,27 +197,24 @@ sub fetch_overdue_workers {
sub update_analysis_stats {
my $self = shift;
my $sql = "SELECT analysis.analysis_id, status, count(*) ".
"FROM analysis_job, analysis ".
"WHERE analysis_job.analysis_id=analysis.analysis_id ".
"GROUP BY analysis_job.analysis_id, status";
my $allAnalysis = $self->db->get_AnalysisAdaptor->fetch_all;
my $statsDBA = $self->db->get_AnalysisStatsAdaptor;
my $analysisStats = undef;
my $sth = $self->prepare($sql);
while (my ($analysis_id, $status, $count)=$sth->fetchrow_array()) {
unless(defined($analysisStats) and $analysisStats->analysis_id==$analysis_id) {
$analysisStats->determine_status()->update() if($analysisStats);
foreach my $analysis (@$allAnalysis) {
$analysisStats = $statsDBA->fetch_by_analysis_id($analysis_id);
my $analysisStats = $analysis->stats;
my $sql = "SELECT status, count(*) FROM analysis_job ".
"WHERE analysis_id=? GROUP BY status";
my $sth = $self->prepare($sql);
while (my ($status, $count)=$sth->fetchrow_array()) {
my $total = $analysisStats->total_job_count();
$analysisStats->total_job_count($total + $count);
......@@ -237,6 +234,8 @@ sub update_analysis_stats {
$analysisStats->determine_status()->update() if($analysisStats);
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