Skip to content

Commit

Permalink
DEV-1069 CRMS: Remove unused Reviewer Activity page (#130)
Browse files Browse the repository at this point in the history
* DEV-1069 CRMS: Remove unused Reviewer Activity page
- Remove reviewActivity.tt and related AJAX and backend Graph.pm support.
- Remove some additional unused Graph.pm routines.
- Remove Highcharts-related checks for reviewerActivity page in header.
  • Loading branch information
moseshll authored Jan 30, 2024
1 parent c1d5aae commit 0b089f2
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 519 deletions.
2 changes: 1 addition & 1 deletion cgi/CRMS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ sub new
return $self;
}

our $VERSION = '8.5.22';
our $VERSION = '8.5.23';
sub Version
{
return $VERSION;
Expand Down
288 changes: 0 additions & 288 deletions cgi/Graph.pm
Original file line number Diff line number Diff line change
Expand Up @@ -260,294 +260,6 @@ sub CreateReviewInstitutionGraph
return \%data;
}

sub CreateReviewerGraph
{
my $self = shift;
my $type = shift;
my $start = shift;
my $end = shift;
my @users = @_;

$type = 0 unless defined $type;
return CreateFlaggedGraph($self, @users) if $type == 3;
my %data = ('chart'=>{'type'=>'spline'}, 'title'=>{'text'=>undef},
'tooltip'=>{'pointFormat'=>'{series.name}: <strong>{point.y}</strong>'},
'xAxis'=>{'categories'=>[], 'labels'=>{'rotation'=>45}},
'yAxis'=>{'min'=>0, 'title'=>{'text'=>'Volumes'}},
'legend'=>{'enabled'=>JSON::XS::true},
'credits'=>{'enabled'=>JSON::XS::false},
'series'=>[]);
$start =~ s/(\d\d\d\d-\d\d)-\d\d/$1/ if defined $start;
$end =~ s/(\d\d\d\d-\d\d)-\d\d/$1/ if defined $end;
$start = $self->SimpleSqlGet('SELECT MIN(monthyear) FROM userstats') unless $start;
$end = $self->SimpleSqlGet('SELECT MAX(monthyear) FROM userstats') unless $end;
my %users;
my %titles = (0=>'Review Count', 1=>'Time Reviewing',
2=>'Invalidation Rate', 3=>'Flagged Reviews');
my %sel = (0=>'SUM(s.total_reviews)',
1=>'SUM(s.total_time/60)',
2=>'ROUND(100*SUM(s.total_incorrect)/SUM(s.total_reviews),2)',
3=>'SUM(s.total_flagged)');
$type = 0 unless defined $titles{$type};
my $title = $titles{$type};
my $sql = 'SELECT DISTINCT monthyear FROM userstats WHERE monthyear>=? AND monthyear<=? ORDER BY monthyear ASC';
#print "$sql, $start, $end\n";
my @dates;
my $ref = $self->SelectAll($sql, $start, $end);
foreach my $row (@{$ref})
{
my $date = $row->[0];
push @dates, $date;
push @{$data{'xAxis'}->{'categories'}}, $self->YearMonthToEnglish($date);
}
my $i = 0;
$data{'yAxis'}->{'title'}->{'text'} = $title;
$data{'yAxis'}->{'labels'}->{'format'} = '{value}%' if $type == 2;
$data{'tooltip'}->{'pointFormat'} = '{series.name}: <strong>{point.y}%</strong>' if $type == 2;
my @colors = PickColors(scalar @users);
foreach my $user (@users)
{
my $ids = $self->GetUserIncarnations($user);
my $name = $self->GetUserProperty($user, 'name');
my $comm = $self->SimpleSqlGet('SELECT commitment FROM users WHERE id=?', $user);
my @counts; # For the inval rate tip
my $wc = $self->WildcardList(scalar @{$ids});
my $h = {'color'=>$colors[$i], 'name'=>$name, 'data'=>[]};
push @{$data{'series'}}, $h;
foreach my $date (@dates)
{
my $sql = 'SELECT ' . $sel{$type} . ' FROM userstats s'.
' WHERE s.monthyear=? AND s.user IN '. $wc;
my $val = $self->SimpleSqlGet($sql, $date, @{$ids});
$val = 0 unless $val;
my $count = 0;
if ($type == 2)
{
$sql = 'SELECT SUM(s.total_reviews) FROM userstats s'.
' WHERE s.monthyear=? AND s.user IN '. $wc;
$count = $self->SimpleSqlGet($sql, $date, @{$ids});
}
if ($type == 1)
{
$sql = 'SELECT COALESCE(SUM(TIME_TO_SEC(r.duration)),0)/3600.0 from reviews r'.
' INNER JOIN users u ON r.id=u.id'.
' WHERE CONCAT(YEAR(DATE(r.time)),"-",MONTH(DATE(r.time)))=?'.
' AND r.user IN '. $wc;
$val += $self->SimpleSqlGet($sql, $date, @{$ids});
}
$val = int($val) if $type == 0;
$val = $val + 0.0 if $type > 0;
if ($type == 1 && defined $comm && 160.0*$comm <= $val)
{
$val = {'y'=>$val, 'marker'=>{'radius'=>8}};
}
elsif ($type == 2 && $val < 6.0 && $count > 0)
{
$val = {'y'=>$val, 'marker'=>{'radius'=>8}};
}
push @{$data{'series'}->[$i]->{'data'}}, $val;
}
$i++;
}
return \%data;
}

sub CreateFlaggedGraph
{
my $self = shift;
my @users = @_;

my %data = ('chart'=>{'type'=>'spline'}, 'title'=>{'text'=>undef},
'tooltip'=>{'pointFormat'=>'{series.name}: <strong>{point.y}</strong>'},
'xAxis'=>{'categories'=>[], 'labels'=>{'rotation'=>45}},
'yAxis'=>{'min'=>0, 'title'=>{'text'=>'Volumes'}},
'legend'=>{'enabled'=>JSON::XS::true},
'credits'=>{'enabled'=>JSON::XS::false},
'series'=>[],
'users'=>[]);
my $sql = 'SELECT DISTINCT DATE(time) d FROM historicalreviews'.
' WHERE time>=DATE_SUB(NOW(), INTERVAL 1 MONTH)'.
' AND user IN ('. join(',',map {"\"$_\"";} @users). ')'.
' ORDER BY d ASC';
#print "$sql\n";
my @dates;
my $ref = $self->SelectAll($sql);
foreach my $row (@{$ref})
{
my $date = $row->[0];
push @dates, $date;
push @{$data{'xAxis'}->{'categories'}}, $date;
}
my $i = 0;
$data{'yAxis'}->{'title'}->{'text'} = 'Flagged Reviews';
my @colors = PickColors(scalar @users);
foreach my $user (@users)
{
my $ids = $self->GetUserIncarnations($user);
my $name = $self->GetUserProperty($user, 'name');
my $wc = $self->WildcardList(scalar @{$ids});
my $h = {'color'=>$colors[$i], 'name'=>$name, 'data'=>[]};
push @{$data{'series'}}, $h;
foreach my $date (@dates)
{
my $sql = 'SELECT COUNT(id) FROM historicalreviews WHERE flagged IS NOT NULL'.
' AND flagged>0 AND DATE(time)=? AND user in '. $wc;
my $val = int($self->SimpleSqlGet($sql, $date, @{$ids}));
$val = 0 unless $val;
push @{$data{'series'}->[$i]->{'data'}}, $val;
}
$i++;
}
return \%data;
}

sub CreateCandidatesGraph2
{
my $self = shift;

my %data = ('chart'=>{'type'=>'spline'}, 'title'=>{'text'=>undef},
'tooltip'=>{'pointFormat'=>'<strong>{point.y}</strong>'},
'xAxis'=>{'categories'=>[], 'labels'=>{'rotation'=>45}},
'yAxis'=>{'min'=>0, 'title'=>{'text'=>'Volumes'}},
'legend'=>{'enabled'=>JSON::XS::false},
'credits'=>{'enabled'=>JSON::XS::false},
'series'=>[{'name'=>'Candidates', 'data'=>[]}]);
my $sql = 'SELECT DATE(time),size FROM candidatessize'.
' WHERE DATE(time)=(SELECT MIN(DATE(time)) FROM candidatessize)'.
' OR DATE(time)=(SELECT MAX(DATE(time)) FROM candidatessize)'.
' OR DATE(time) LIKE "%-01"'.
' ORDER BY DATE(time) ASC';
my $ref = $self->SelectAll($sql);
my @titles;
my @vals;
foreach my $row (@{$ref})
{
my ($d,$cnt) = ($row->[0], $row->[1]);
push @titles, $d;
push @vals, $cnt;
}
foreach my $i (0 .. scalar @vals - 1)
{
push @{$data{'xAxis'}->{'categories'}}, $titles[$i];
push @{$data{'series'}->[0]->{'data'}}, int($vals[$i]);
}
return \%data;
}

sub CreateCandidatesGraph3
{
my $self = shift;

my %data = ('chart'=>{'type'=>'spline'}, 'title'=>{'text'=>undef},
'tooltip'=>{'pointFormat'=>'<strong>{point.y}</strong>'},
'xAxis'=>{'categories'=>[], 'labels'=>{'rotation'=>45}},
'yAxis'=>{'min'=>0, 'title'=>{'text'=>'Volumes'}},
'legend'=>{'enabled'=>JSON::XS::false},
'credits'=>{'enabled'=>JSON::XS::false},
'series'=>[{'name'=>'Candidates', 'data'=>[]}]);
my $sql = 'SELECT DISTINCT(DATE(time)) FROM exportdata'.
' WHERE DATE(time)=(SELECT MIN(DATE(time)) FROM exportdata)'.
' OR DATE(time)=(SELECT MAX(DATE(time)) FROM exportdata)'.
' OR DATE(time) LIKE "%-01"'.
' ORDER BY DATE(time) DESC';
my $size = $self->GetCandidatesSize();
my $ref = $self->SelectAll($sql);
my @titles;
my @vals;
my $i;
push @titles, $ref->[0]->[0];
push @vals, $size;
#print "Starting size $size\n";
foreach my $i (1 .. scalar @{$ref} - 2)
{
# second date is earlier
$sql = 'SELECT COUNT(*) FROM exportdata WHERE DATE(time)>? AND DATE(time)<=? AND (src="candidates" OR src="cri" OR src="inherited")';
my $cnt = $self->SimpleSqlGet($sql, $ref->[$i+1]->[0], $ref->[$i]->[0]);
$size += $cnt;
#printf "%s to %s: $cnt, size now $size\n", $ref->[$i+1]->[0], $ref->[$i]->[0];
push @titles, $ref->[$i]->[0];
push @vals, $size;
}
$sql = 'SELECT COUNT(*) FROM exportdata WHERE DATE(time)<=? AND (src="candidates" OR src="cri" OR src="inherited")';
my $cnt = $self->SimpleSqlGet($sql, $ref->[scalar @{$ref}-2]->[0]);
push @titles, $ref->[scalar @{$ref}-1]->[0];
push @vals, $size+$cnt;
@titles = reverse @titles;
@vals = reverse @vals;
foreach my $i (0 .. scalar @vals - 1)
{
push @{$data{'xAxis'}->{'categories'}}, $titles[$i];
push @{$data{'series'}->[0]->{'data'}}, int($vals[$i]);
}
return \%data;
}

sub CreateProgressGraph
{
my $self = shift;
my $project = shift;

my $proj = $self->SimpleSqlGet('SELECT COALESCE(id,1) FROM projects WHERE name=?', $project);
my $sql = 'SELECT COUNT(*) FROM exportdata WHERE project=?';
my $val = $self->SimpleSqlGet($sql, $proj);
$sql = 'SELECT COUNT(*) FROM candidates WHERE project=?';
my $n = $self->SimpleSqlGet($sql, $proj);
my $total = $val + $n;
my $ticks = NearestMultiple(1000, $total/10);
my $fmt = '<div style="text-align:center">'.
'<span style="font-size:25px;color:black">{y} of '. $total. '</span><br/>'.
'<span style="font-size:12px;color:silver">determinations</span></div>';
my %data = ('chart'=>{'type'=>'solidgauge'},
'title'=>{'text'=>'<span style="font-size:25px;color:black">'. $project. ' Project</span><br/>'},
'pane'=>{'center'=>['50%','85%'],
'size'=>'120%',
'startAngle'=>'-90',
'endAngle'=>'90',
'background'=>{'backgroundColor'=>'#EEE',
'innerRadius'=>'60%',
'outerRadius'=>'100%',
'shape'=>'arc'}},
'tooltip'=>{'enabled'=>JSON::XS::false},
'yAxis'=>{'stops'=>[[0.0, '#DF5353'],[0.5, '#DDDF0D'],[1.0, '#55BF3B']],
'min'=>0,
'max'=>$total,
'lineWidth'=>1,
'minorTickInterval'=>undef,
'tickInterval'=>$ticks,
'tickWidth'=>1,
'title'=>{'y'=>-70},
'labels'=>{'y'=>16}},
'plotOptions'=>{'solidgauge'=>{'dataLabels'=>{'y'=>5,'borderWidth'=>0,'useHTML'=>JSON::XS::true}}},
'credits'=>{'enabled'=>JSON::XS::false},
'series'=>[{'name'=>'Determinations',
'data'=>[$val],
'dataLabels'=>{'format'=>$fmt},
}]);
return \%data;
}

sub CreateInheritanceGraph
{
my $self = shift;

my %data = ('chart'=>{'type'=>'spline'}, 'title'=>{'text'=>undef},
'tooltip'=>{'pointFormat'=>'<strong>{point.y}</strong>'},
'xAxis'=>{'categories'=>[], 'labels'=>{'rotation'=>45}},
'yAxis'=>{'min'=>0, 'title'=>{'text'=>'Inheritances'}},
'legend'=>{'enabled'=>JSON::XS::false},
'credits'=>{'enabled'=>JSON::XS::false},
'series'=>[{'name'=>'Exports', 'data'=>[]}]);
my $sql = 'SELECT DATE_FORMAT(DATE(time),"%b %Y") AS fmt,COUNT(*) FROM exportdata'.
' WHERE src="inherited" GROUP BY DATE_FORMAT(DATE(time),"%Y-%m")';
my $ref = $self->SelectAll($sql);
foreach my $row (@{$ref})
{
push @{$data{'xAxis'}->{'categories'}}, $row->[0];
push @{$data{'series'}->[0]->{'data'}}, int($row->[1]);
}
return \%data;
}

sub PickColors
{
my $count = shift;
Expand Down
13 changes: 0 additions & 13 deletions cgi/getExportStats
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,6 @@ if ($type eq 'graph')
elsif ($c == 6) { $data = Graph::CreateUndGraph($crms); }
elsif ($c == 7) { $data = Graph::CreateNamespaceGraph($crms); }
elsif ($c == 9) { $data = Graph::CreateReviewInstitutionGraph($crms); }
elsif ($c == 10)
{
my $start = $cgi->param('startDate');
my $end = $cgi->param('endDate');
my $type2 = $cgi->param('type2');
my @users = $cgi->param('user');
$data = Graph::CreateReviewerGraph($crms, $type2, $start, $end, @users);
}
elsif ($c == 11)
{
my $proj = $cgi->param('project');
$data = Graph::CreateProgressGraph($crms, $proj);
}
}
else
{
Expand Down
5 changes: 1 addition & 4 deletions cgi/header.tt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
[% IF crms.get('debugSql') || crms.get('debugVar') %]
<link rel="stylesheet" type="text/css" href="[% crms.WebPath('web', 'css/debug.css') %]"/>
[% END %]
[% IF page == 'exportStats' OR page == 'reviewerActivity' %]
[% IF page == 'exportStats' %]
<script src="https://code.highcharts.com/adapters/standalone-framework.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
[% IF page == 'reviewerActivity' %]
<script src="https://code.highcharts.com/modules/exporting.js"></script>
[% END %]
[% END %]

<link rel="stylesheet" type="text/css" href="[% crms.WebPath('web', 'css/review.css') %]"/>
Expand Down
16 changes: 0 additions & 16 deletions cgi/home.tt
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,6 @@ function CheckAll(box,formid)
aa.elements[i].checked = box.checked;
}
}

window.onload = function(e)
{
var progress = document.getElementById('progress');
if (progress)
{
try
{
loadChart(progress, "[% crms.WebPath('cgi', 'getExportStats?type=graph&c=11&project=State+Gov+Docs') %]");
}
catch (e)
{
//alert('Problem loading chart: '+e);
}
}
}
-->
</script>

Expand Down
Loading

0 comments on commit 0b089f2

Please sign in to comment.