From 801e449aa3b344f2295578e6a15fdb6b849d0863 Mon Sep 17 00:00:00 2001 From: Moses Hall Date: Thu, 18 Jan 2024 16:40:46 -0500 Subject: [PATCH] DEV-1022 Remove Determinations Breakdown page - Remove everything that reads or modifies `crms.determinationsbreakdown` and `crms.predeterminationsbreakdown`. - Remove the Determinations Breakdown page template and everything that inhabits it. --- cgi/CRMS.pm | 266 ------------------------------ cgi/Downloads.pm | 29 ---- cgi/Graph.pm | 33 ---- cgi/determinationStats.tt | 66 -------- cgi/getExportStats | 1 - cgi/header.tt | 2 +- docker/db/sql/001_crms_schema.sql | 36 ---- 7 files changed, 1 insertion(+), 432 deletions(-) delete mode 100755 cgi/determinationStats.tt diff --git a/cgi/CRMS.pm b/cgi/CRMS.pm index 62c1e89f..76a2125d 100755 --- a/cgi/CRMS.pm +++ b/cgi/CRMS.pm @@ -748,9 +748,6 @@ sub ProcessReviews $self->SetSystemStatus($stat); $sql = 'INSERT INTO processstatus VALUES ()'; $self->PrepareSubmitSql($sql); - $self->PrepareSubmitSql('DELETE FROM predeterminationsbreakdown WHERE date=DATE(NOW())'); - $sql = 'INSERT INTO predeterminationsbreakdown (date,s2,s3,s4,s8) VALUES (DATE(NOW()),?,?,?,?)'; - $self->PrepareSubmitSql($sql, $stati{2}, $stati{3}, $stati{4}, $stati{8}); } # Returns a data structure with the following fields: @@ -889,7 +886,6 @@ sub ClearQueueAndExport push @export, $_->[0] for @{$double}; $self->ExportReviews(\@export, $quiet); $self->UpdateExportStats(); - $self->UpdateDeterminationsBreakdown(); my $msg = sprintf 'Removed from queue: %d matching, %d expert-reviewed, %d auto-resolved, %d inherited', scalar @{$double}, scalar @{$expert}, scalar @{$auto}, scalar @{$inh}; } @@ -4154,30 +4150,6 @@ sub CreateExportData push @{$data{$title}}, $self->SimpleSqlGet($sql, @params); } } - # Append in the Status breakdown - foreach my $status (4 .. 9) - { - my $title = 'Status '.$status; - push @titles, $title; - $data{$title} = []; - foreach my $date (@dates) - { - Utilities::ClearArrays(\@clauses, \@params); - $sql = 'SELECT COALESCE(SUM(s'. $status.'),0) FROM determinationsbreakdown'; - if ($date =~ m/^\d+/) - { - push @clauses, $fmt; - push @params, $date; - } - elsif ($date eq 'Total' && defined $year) - { - push @clauses, $fmt2; - push @params, $year; - } - $sql .= ' WHERE '. join ' AND ', @clauses if scalar @clauses; - push @{$data{$title}}, $self->SimpleSqlGet($sql, @params); - } - } # Now that total is available, decorate with percentages. if ($pct) { @@ -4253,227 +4225,6 @@ sub CreateExportReport return $report; } -sub CreatePreDeterminationsBreakdownData -{ - my $self = shift; - my $start = shift; - my $end = shift; - my $monthly = shift; - my $title = shift; - - my ($year,$month) = $self->GetTheYearMonth(); - my $titleDate = $self->YearMonthToEnglish("$year-$month"); - my $justThisMonth = (!$start && !$end); - $start = "$year-$month-01" unless $start; - my $lastDay = Days_in_Month($year,$month); - $end = "$year-$month-$lastDay" unless $end; - my $what = 'date'; - $what = 'DATE_FORMAT(date, "%Y-%m")' if $monthly; - my $sql = 'SELECT DISTINCT(' . $what . ') FROM predeterminationsbreakdown WHERE date>=? AND date<=?'; - #print "$sql
\n"; - my @dates = map {$_->[0];} @{$self->SelectAll($sql, $start, $end)}; - if (scalar @dates && !$justThisMonth) - { - my $startEng = $self->YearMonthToEnglish(substr($dates[0],0,7)); - my $endEng = $self->YearMonthToEnglish(substr($dates[-1],0,7)); - $titleDate = ($startEng eq $endEng)? $startEng:sprintf("%s to %s", $startEng, $endEng); - } - my $report = ($title)? "$title\n":"Preliminary Determinations Breakdown $titleDate\n"; - my @titles = ('Date','Status 2','Status 3','Status 4','Status 8','Total','Status 2','Status 3','Status 4','Status 8'); - $report .= join("\t", @titles) . "\n"; - my @totals = (0,0,0,0); - foreach my $date (@dates) - { - my ($y,$m,$d) = split '-', $date; - my $date1 = $date; - my $date2 = $date; - if ($monthly) - { - $date1 = "$date-01"; - my $lastDay = Days_in_Month($y,$m); - $date2 = "$date-$lastDay"; - $date = $self->YearMonthToEnglish($date); - } - my $sql = 'SELECT s2,s3,s4,s8,s2+s3+s4+s8 FROM predeterminationsbreakdown WHERE date LIKE "' . $date1 . '%"'; - #print "$sql
\n"; - my ($s2,$s3,$s4,$s8,$sum) = @{$self->SelectAll($sql)->[0]}; - my @line = ($s2,$s3,$s4,$s8,$sum,0,0,0,0); - next unless $sum > 0; - for (my $i=0; $i < 4; $i++) - { - $totals[$i] += $line[$i]; - } - for (my $i=0; $i < 4; $i++) - { - my $pct = 0.0; - eval {$pct = 100.0*$line[$i]/$line[4];}; - $line[$i+5] = sprintf('%.1f%%', $pct); - } - $report .= $date; - $report .= "\t" . join("\t", @line) . "\n"; - } - my $gt = $totals[0] + $totals[1] + $totals[2] + $totals[3]; - push @totals, $gt; - for (my $i=0; $i < 5; $i++) - { - my $pct = 0.0; - eval {$pct = 100.0*$totals[$i]/$gt;}; - push @totals, sprintf('%.1f%%', $pct); - } - $report .= "Total\t" . join("\t", @totals) . "\n"; - return $report; -} - -sub CreateDeterminationsBreakdownData -{ - my $self = shift; - my $start = shift; - my $end = shift; - my $monthly = shift; - my $title = shift; - - my ($year,$month) = $self->GetTheYearMonth(); - my $titleDate = $self->YearMonthToEnglish("$year-$month"); - my $justThisMonth = (!$start && !$end); - $start = "$year-$month-01" unless $start; - my $lastDay = Days_in_Month($year,$month); - $end = "$year-$month-$lastDay" unless $end; - my $what = 'date'; - $what = 'DATE_FORMAT(date, "%Y-%m")' if $monthly; - my $sql = 'SELECT DISTINCT(' . $what . ') FROM determinationsbreakdown WHERE date>=? AND date<=?'. - ' ORDER BY date DESC'; - #print "$sql
\n"; - my @dates = map {$_->[0];} @{$self->SelectAll($sql, $start, $end)}; - if (scalar @dates && !$justThisMonth) - { - my $startEng = $self->YearMonthToEnglish(substr($dates[0],0,7)); - my $endEng = $self->YearMonthToEnglish(substr($dates[-1],0,7)); - $titleDate = ($startEng eq $endEng)? $startEng:sprintf("%s to %s", $startEng, $endEng); - } - my $report = ($title)? "$title\n":"Determinations Breakdown $titleDate\n"; - my @titles = ('Date','Status 4','Status 5','Status 6','Status 7','Status 8','Subtotal', - 'Status 9','Total','Status 4','Status 5','Status 6','Status 7','Status 8'); - $report .= join("\t", @titles) . "\n"; - my @totals = (0,0,0,0,0,0); - foreach my $date (@dates) - { - my ($y,$m,$d) = split '-', $date; - my $date1 = $date; - my $date2 = $date; - if ($monthly) - { - $date1 = $date . '-01'; - my $lastDay = Days_in_Month($y,$m); - $date2 = "$date-$lastDay"; - $date = $self->YearMonthToEnglish($date); - } - $sql = 'SELECT SUM(s4),SUM(s5),SUM(s6),SUM(s7),SUM(s8),SUM(s4+s5+s6+s7+s8),SUM(s9),SUM(s4+s5+s6+s7+s8+s9)' . - ' FROM determinationsbreakdown WHERE date>=? AND date<=?'; - #print "$sql
\n"; - my ($s4,$s5,$s6,$s7,$s8,$sum1,$s9,$sum2) = @{$self->SelectAll($sql, $date1, $date2)->[0]}; - my @line = ($s4,$s5,$s6,$s7,$s8,$sum1,$s9,$sum2,0,0,0,0,0); - next unless $sum1 > 0; - for (my $i=0; $i < 5; $i++) - { - $totals[$i] += $line[$i]; - } - $totals[5] += $line[6]; - for (my $i=0; $i < 5; $i++) - { - my $pct = 0.0; - eval {$pct = 100.0*$line[$i]/$line[5];}; - $line[$i+8] = sprintf('%.1f%%', $pct); - } - $report .= $date; - $report .= "\t". join("\t", @line). "\n"; - } - my $gt1 = $totals[0] + $totals[1] + $totals[2] + $totals[3] + $totals[4]; - my $gt2 = $gt1 + $totals[5]; - splice @totals, 5, 0, $gt1; - push @totals, $gt2; - for (my $i=0; $i < 5; $i++) - { - my $pct = 0.0; - eval {$pct = 100.0*$totals[$i]/$gt1;}; - push @totals, sprintf('%.1f%%', $pct); - } - $report .= "Total\t" . join("\t", @totals) . "\n"; - return $report; -} - -sub CreateDeterminationsBreakdownReport -{ - my $self = shift; - my $start = shift; - my $end = shift; - my $monthly = shift; - my $title = shift; - my $pre = shift; - - my $data; - my %whichlines = (5=>1,7=>1); - my $span1 = 8; - my $span2 = 5; - if ($pre) - { - $data = $self->CreatePreDeterminationsBreakdownData($start, $end, $monthly, $title); - %whichlines = (4=>1); - $span1 = 5; - $span2 = 4; - } - else - { - $data = $self->CreateDeterminationsBreakdownData($start, $end, $monthly, $title); - $pre = 0; - } - my $cols = $span1 + $span2; - my @lines = split "\n", $data; - $title = shift @lines; - $title =~ s/\s/ /g; - my $url = $self->Sysify(sprintf("?p=determinationStats;startDate=$start;endDate=$end;%sdownload=1;pre=$pre",($monthly)?'monthly=on;':'')); - my $link = sprintf("Download",); - my $report = "

$title    $link

\n"; - $report .= "\n"; - $report .= "\n"; - my $titles = shift @lines; - $report .= ('' . join('', map {my $tmp = $_; $tmp =~ s/\s/ /g; "";} split("\t", $titles)) . ''); - foreach my $line (@lines) - { - my @line = split "\t", $line; - my $date = shift @line; - my ($y,$m,$d) = split '-', $date; - $date =~ s/\s/ /g; - if ($date eq 'Total') - { - $report .= ""; - } - else - { - $report .= ""; - } - for (my $i=0; $i < $cols; $i++) - { - my $class = ''; - my $style = ($i==max keys %whichlines)? "style='border-right:double 6px black;'":''; - if ($whichlines{$i} && $date ne 'Total') - { - $class = 'class="minor"'; - } - elsif ($date ne 'Total') - { - $class = 'class="total"'; - $class = 'class="major"' if $i < max keys %whichlines; - } - my $val = $line[$i]; - $val = '' if $val eq '0' or $val eq '0.0%'; - $report .= "\n"; - } - $report .= "\n"; - } - $report .= "
CountsPercentages
$tmp
Total
$date$val
\n"; - return $report; -} - sub GetUserStatsYears { my $self = shift; @@ -4637,23 +4388,6 @@ sub GetMonthStats $total_flagged); } -sub UpdateDeterminationsBreakdown -{ - my $self = shift; - my $date = shift; - - $date = $self->SimpleSqlGet('SELECT CURDATE()') unless $date; - my @vals = ($date); - foreach my $status (4..9) - { - my $sql = 'SELECT COUNT(gid) FROM exportdata WHERE DATE(time)=? AND status=?'; - push @vals, $self->SimpleSqlGet($sql, $date, $status); - } - my $wcs = $self->WildcardList(scalar @vals); - my $sql = 'REPLACE INTO determinationsbreakdown (date,s4,s5,s6,s7,s8,s9) VALUES '. $wcs; - $self->PrepareSubmitSql($sql, @vals); -} - sub UpdateExportStats { my $self = shift; diff --git a/cgi/Downloads.pm b/cgi/Downloads.pm index adfaeeff..0ae758f2 100644 --- a/cgi/Downloads.pm +++ b/cgi/Downloads.pm @@ -43,14 +43,6 @@ sub Download $search2, $search2value, $startDate, $endDate, $offset, $records); } - elsif ($page eq 'determinationStats') - { - my $monthly = $cgi->param('monthly'); - my $priority = $cgi->param('priority'); - my $pre = $cgi->param('pre'); - DownloadDeterminationStats($crms, $startDate, $endDate, $monthly, - $priority, $pre); - } elsif ($page eq 'exportData') { DownloadExportData($crms, $order, $dir, $search1, $search1value, $op1, @@ -143,27 +135,6 @@ sub DownloadCandidates DownloadSpreadsheet($buff); } -sub DownloadDeterminationStats -{ - my $crms = shift; - my $startDate = shift; - my $endDate = shift; - my $monthly = shift; - my $priority = shift; - my $pre = shift; - - my $buff; - if ($pre) - { - $buff = $crms->CreatePreDeterminationsBreakdownData($startDate, $endDate, $monthly, undef, $priority); - } - else - { - $buff = $crms->CreateDeterminationsBreakdownData($startDate, $endDate, $monthly, undef, $priority); - } - DownloadSpreadsheet($buff); -} - sub DownloadExportData { my $crms = shift; diff --git a/cgi/Graph.pm b/cgi/Graph.pm index 8b99aa90..2a226526 100644 --- a/cgi/Graph.pm +++ b/cgi/Graph.pm @@ -61,39 +61,6 @@ sub CreateExportBreakdownGraph return \%data; } -sub CreateDeterminationsBreakdownGraph -{ - my $self = shift; - - my %data = ('chart'=>{'type'=>'spline'}, 'title'=>{'text'=>undef}, - 'tooltip'=>{'pointFormat'=>'{point.y}'}, - 'xAxis'=>{'categories'=>[], 'labels'=>{'rotation'=>45}}, - 'yAxis'=>{'min'=>0, 'title'=>{'text'=>'Volumes'}}, - 'legend'=>{'enabled'=>JSON::XS::true}, - 'credits'=>{'enabled'=>JSON::XS::false}, - 'series'=>[]); - my @titles = ('Status 4', 'Status 5', 'Status 6', 'Status 7', 'Status 8', 'Status 9'); - my @colors = PickColors(scalar @titles, 1); - my $i = 0; - foreach my $title (@titles) - { - my $h = {'color'=>$colors[$i], 'name'=>$title, 'data'=>[]}; - push @{$data{'series'}}, $h; - $i++; - } - $data{'series'}->[$_]->{'color'} = $colors[$_] for (0..2); - my $sql = 'SELECT DATE_FORMAT(date,"%b %Y") AS fmt,SUM(s4),SUM(s5),SUM(s6),SUM(s7),SUM(s8),SUM(s9)'. - ' FROM determinationsbreakdown'. - ' GROUP BY fmt ORDER BY date ASC'; - my $ref = $self->SelectAll($sql); - foreach my $row (@{$ref}) - { - push @{$data{'xAxis'}->{'categories'}}, $row->[0]; - push(@{$data{'series'}->[$_]->{'data'}}, int($row->[$_+1])) for (0..5); - } - return \%data; -} - sub CreateCandidatesData { my $self = shift; diff --git a/cgi/determinationStats.tt b/cgi/determinationStats.tt deleted file mode 100755 index 4b8e3069..00000000 --- a/cgi/determinationStats.tt +++ /dev/null @@ -1,66 +0,0 @@ -[% INCLUDE header.tt %] - - - - - -

Determinations Breakdown:

- -[% page = cgi.param('p') %] -[% startDate = cgi.param('startDate') %] -[% endDate = cgi.param('endDate') %] - -
- -
-
- - - - -(YYYY-MM-DD) -
- - - -(YYYY-MM-DD) -
- - -[% crms.HiddenSys %] -
-
-
- - -[% #crms.CreateDeterminationsBreakdownReport(startDate, endDate, 0, undef, 1) %] -[% crms.CreateDeterminationsBreakdownReport(startDate, endDate, 0, undef) %] -

-[% crms.CreateDeterminationsBreakdownReport('2009-07-01' 0, 1, 'Project Determinations Breakdown') %] -

- -
- -[% INCLUDE footer.tt %] diff --git a/cgi/getExportStats b/cgi/getExportStats index b647b0e6..100e009b 100755 --- a/cgi/getExportStats +++ b/cgi/getExportStats @@ -27,7 +27,6 @@ if ($type eq 'graph') if ($c == 0) { $data = Graph::CreateExportGraph($crms); } elsif ($c == 1) { $data = Graph::CreateExportBreakdownGraph($crms); } elsif ($c == 2) { $data = Graph::CreateExportsPieChart($crms); } - elsif ($c == 3) { $data = Graph::CreateDeterminationsBreakdownGraph($crms); } elsif ($c == 4) { $data = Graph::CreateCandidatesGraph($crms); } elsif ($c == 5) { $data = Graph::CreateCountriesGraph($crms); } elsif ($c == 6) { $data = Graph::CreateUndGraph($crms); } diff --git a/cgi/header.tt b/cgi/header.tt index 7ed08f8d..c964bdaf 100644 --- a/cgi/header.tt +++ b/cgi/header.tt @@ -18,7 +18,7 @@ [% IF crms.get('debugSql') || crms.get('debugVar') %] [% END %] - [% IF page == 'determinationStats' OR page == 'exportStats' OR page == 'reviewerActivity' %] + [% IF page == 'exportStats' OR page == 'reviewerActivity' %] [% IF page == 'reviewerActivity' %] diff --git a/docker/db/sql/001_crms_schema.sql b/docker/db/sql/001_crms_schema.sql index dd90979d..33bf3fd0 100644 --- a/docker/db/sql/001_crms_schema.sql +++ b/docker/db/sql/001_crms_schema.sql @@ -533,25 +533,6 @@ CREATE TABLE `dbo_T_code` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `determinationsbreakdown` --- - -DROP TABLE IF EXISTS `determinationsbreakdown`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `determinationsbreakdown` ( - `date` date NOT NULL, - `s4` int(11) NOT NULL DEFAULT '0', - `s5` int(11) NOT NULL DEFAULT '0', - `s6` int(11) NOT NULL DEFAULT '0', - `s7` int(11) NOT NULL DEFAULT '0', - `s8` int(11) NOT NULL DEFAULT '0', - `s9` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`date`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `exportdata` -- @@ -831,23 +812,6 @@ CREATE TABLE `orphan` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `predeterminationsbreakdown` --- - -DROP TABLE IF EXISTS `predeterminationsbreakdown`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `predeterminationsbreakdown` ( - `date` date NOT NULL, - `s2` int(11) NOT NULL DEFAULT '0', - `s3` int(11) NOT NULL DEFAULT '0', - `s4` int(11) NOT NULL DEFAULT '0', - `s8` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`date`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `processstatus` --