Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addresses 153 Remove historicalreviews.flagged column #180

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 4 additions & 56 deletions cgi/CRMS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1920,18 +1920,6 @@ sub MoveFromReviewsToHistoricalReviews
$self->PrepareSubmitSql($sql, $gid, $id);
$sql = 'DELETE FROM reviews WHERE id=?';
$self->PrepareSubmitSql($sql, $id);
$sql = 'SELECT user FROM historicalreviews WHERE gid=?';
my $ref = $self->SelectAll($sql, $gid);
foreach my $row (@{$ref})
{
my $user = $row->[0];
my $flag = $self->ShouldReviewBeFlagged($gid, $user);
if (defined $flag)
{
$sql = 'UPDATE historicalreviews SET flagged=? WHERE gid=? AND user=?';
$self->PrepareSubmitSql($sql, $flag, $gid, $user);
}
}
}

sub GetFinalAttrReason
Expand Down Expand Up @@ -4369,16 +4357,15 @@ sub GetMonthStats
{
$reviews_per_hour = (60/$time_per_review);
}
my ($total_correct,$total_incorrect,$total_neutral,$total_flagged) = $self->CountCorrectReviews($user, $start, $end, $proj);
my ($total_correct,$total_incorrect,$total_neutral) = $self->CountCorrectReviews($user, $start, $end, $proj);
$sql = 'INSERT INTO userstats (user,month,year,monthyear,project,'.
'total_reviews,total_pd,total_ic,total_und,total_time,time_per_review,'.
'reviews_per_hour,total_outliers,total_correct,total_incorrect,'.
'total_neutral,total_flagged) VALUES ' . $self->WildcardList(17);
'total_neutral) VALUES ' . $self->WildcardList(16);
$self->PrepareSubmitSql($sql, $user, $m, $y, $y. '-'. $m, $proj, $total_reviews,
$total_pd, $total_ic, $total_und, $total_time,
$time_per_review, $reviews_per_hour, $total_outliers,
$total_correct, $total_incorrect, $total_neutral,
$total_flagged);
$total_correct, $total_incorrect, $total_neutral);
}

sub UpdateExportStats
Expand Down Expand Up @@ -5764,12 +5751,7 @@ sub CountCorrectReviews
$correct = $cnt if $val == 1;
$neutral = $cnt if $val == 2;
}
$sql = 'SELECT COUNT(*) FROM historicalreviews r'.
' INNER JOIN exportdata e ON r.gid=e.gid'.
' WHERE r.legacy!=1 AND r.user=? AND r.time>=? AND r.time<=?'.
' AND e.project=? AND r.flagged IS NOT NULL AND r.flagged>0';
my $flagged = $self->SimpleSqlGet($sql, $user, $start, $end, $proj);
return ($correct, $incorrect, $neutral, $flagged);
return ($correct, $incorrect, $neutral);
}

# Gets only those reviewers that are not experts
Expand Down Expand Up @@ -5800,40 +5782,6 @@ sub GetValidation
return @{ $row };
}

sub ShouldReviewBeFlagged
{
my $self = shift;
my $user = shift;
my $gid = shift;

my ($pd, $icren, $date, $wr);
my $sql = 'SELECT r.user,a.name,rs.name,r.category,r.validated FROM historicalreviews r'.
' INNER JOIN exportdata e ON r.gid=e.gid'.
' INNER JOIN attributes a ON r.attr=a.id'.
' INNER JOIN reasons rs ON r.reason=rs.id'.
' WHERE r.gid=? ORDER BY IF(r.user=?,1,0) DESC';
my $ref = $self->SelectAll($sql, $gid, $user);
foreach my $row (@{$ref})
{
my ($user2, $attr, $reason, $category, $val) = @{$row};
if ($user2 eq $user)
{
return if $val == 1;
$pd = 1 if $attr =~ m/^pd/;
}
else
{
$icren = 1 if $attr eq 'ic' and $reason eq 'ren';
$date = 1 if $attr eq 'und' and $reason eq 'nfi' and $category eq 'Date';
$wr = 1 if $attr eq 'und' and $reason eq 'nfi' and $category eq 'Wrong Record';
}
}
return if !$pd;
return 1 if $icren;
return 2 if $date;
return 3 if $wr;
}

sub ReviewSearchMenu
{
my $self = shift;
Expand Down
2 changes: 0 additions & 2 deletions docker/db/sql/001_crms_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@ CREATE TABLE `historicalreviews` (
`swiss` tinyint(1) DEFAULT NULL,
`validated` tinyint(4) NOT NULL DEFAULT '1',
`gid` bigint(20) DEFAULT NULL,
`flagged` int(11) DEFAULT NULL,
`data` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`,`time`,`user`),
KEY `attr_idx` (`attr`),
Expand Down Expand Up @@ -1150,7 +1149,6 @@ CREATE TABLE `userstats` (
`total_correct` int(11) DEFAULT NULL,
`total_incorrect` int(11) DEFAULT NULL,
`total_neutral` int(11) DEFAULT NULL,
`total_flagged` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`user`,`monthyear`,`project`),
KEY `fk_project` (`project`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Expand Down