diff --git a/cgi/CRMS.pm b/cgi/CRMS.pm index 76a2125d..4ff3c960 100755 --- a/cgi/CRMS.pm +++ b/cgi/CRMS.pm @@ -66,7 +66,7 @@ sub new return $self; } -our $VERSION = '8.5.22'; +our $VERSION = '8.5.23'; sub Version { return $VERSION; diff --git a/cgi/Graph.pm b/cgi/Graph.pm index 2a226526..f5fc7210 100644 --- a/cgi/Graph.pm +++ b/cgi/Graph.pm @@ -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}: {point.y}'}, - '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}: {point.y}%' 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}: {point.y}'}, - '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'=>'{point.y}'}, - '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'=>'{point.y}'}, - '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 = '
'. - '{y} of '. $total. '
'. - 'determinations
'; - my %data = ('chart'=>{'type'=>'solidgauge'}, - 'title'=>{'text'=>''. $project. ' Project
'}, - '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'=>'{point.y}'}, - '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; diff --git a/cgi/getExportStats b/cgi/getExportStats index 100e009b..95f328cf 100755 --- a/cgi/getExportStats +++ b/cgi/getExportStats @@ -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 { diff --git a/cgi/header.tt b/cgi/header.tt index c964bdaf..e4767923 100644 --- a/cgi/header.tt +++ b/cgi/header.tt @@ -18,12 +18,9 @@ [% IF crms.get('debugSql') || crms.get('debugVar') %] [% END %] - [% IF page == 'exportStats' OR page == 'reviewerActivity' %] + [% IF page == 'exportStats' %] - [% IF page == 'reviewerActivity' %] - - [% END %] [% END %] diff --git a/cgi/home.tt b/cgi/home.tt index 1d512fce..fbac7f2d 100755 --- a/cgi/home.tt +++ b/cgi/home.tt @@ -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); - } - } -} --> diff --git a/cgi/reviewerActivity.tt b/cgi/reviewerActivity.tt deleted file mode 100644 index 3dbc1258..00000000 --- a/cgi/reviewerActivity.tt +++ /dev/null @@ -1,197 +0,0 @@ -[% INCLUDE header.tt %] - - - - - - - - -
- - - - - -
-
- - - - (YYYY-MM-DD) -
- - - - (YYYY-MM-DD) -
-

- [% actives = [] %] -
-
- [% sql = "SELECT id,shortname FROM institutions WHERE id!=0 ORDER BY shortname ASC" %] - [% ref = crms.SelectAll(sql) %] - - [% i = 1 %] - [% col = 0 %] - [% FOREACH r IN ref %] - [% revs = crms.GetInstitutionReviewers(r.0) %] - [% IF revs.size() > 0 %] - [% IF (i >= ref.size() / 2 && col == 0) %] - [% col = col + 1 %] -
-
- - [% END %] - [% i = i + 1 %] - - [% END %] - [% FOREACH h IN revs %] - - [% id = h.id.replace('@', '__AT__') %] - [% name = h.name %] - - - - [% END %] - [% END %] -
- - -
- - - [% IF h.commitment %][% 100 * h.commitment %]%[% END %]
-

-[% json = '["' _ actives.join('","') _ '"]' %] - - -[% INCLUDE footer.tt %] -