Skip to content

Commit

Permalink
Use rflags to compute PaperContactInfo.
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed Feb 9, 2024
1 parent 4888577 commit 4d2aa24
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -4147,7 +4147,7 @@ function can_view_review_identity(PaperInfo $prow, $rbase = null) {
&& $rights->review_status > PaperContactInfo::CIRS_UNSUBMITTED)
|| ($seerevid_setting === Conf::VIEWREV_IFASSIGNED
&& $rights->reviewType > 0
&& !$rights->self_assigned
&& !$rights->self_assigned()
&& $rights->review_status > 0);
}

Expand Down
2 changes: 1 addition & 1 deletion src/papercolumns/pc_assignreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function content(PaperList $pl, PaperInfo $row) {
} else {
$rt = ReviewInfo::unparse_type(min(max($ci->reviewType, 0), REVIEW_META));
}
$rs = $ci->reviewSubmitted ? " s" : "";
$rs = $ci->review_submitted() ? " s" : "";
$pl->need_render = true;
$t = '<span class="need-assignment-selector';
if (!$this->contact->can_accept_review_assignment_ignore_conflict($row)
Expand Down
63 changes: 32 additions & 31 deletions src/paperinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ class PaperContactInfo {
/** @var int */
public $conflictType = 0;
/** @var int */
public $reviewType = 0;
/** @var bool */
public $self_assigned = false;
public $rflags = 0;
/** @var int */
public $reviewSubmitted = 0;
public $reviewType = 0;
/** @var int */
public $reviewRound = 0;
/** @var int */
Expand Down Expand Up @@ -160,32 +158,35 @@ static function make_my($prow, $user) {
return $ci;
}

/** @return bool */
function self_assigned() {
return ($this->rflags & ReviewInfo::RF_SELF_ASSIGNED) !== 0;
}

/** @return bool */
function review_submitted() {
return ($this->rflags & ReviewInfo::RF_SUBMITTED) !== 0;
}

/** @param int $ct */
function mark_conflict($ct) {
$this->conflictType = max($ct, $this->conflictType);
}

/** @param Conf $conf
* @param int $reviewType
* @param int $reviewSubmitted
* @param int $rflags
* @param int $reviewNeedsSubmit
* @param int $reviewRound
* @param int $requestedBy */
private function mark_review_type($conf, $reviewType,
$reviewSubmitted, $reviewNeedsSubmit, $reviewRound,
$requestedBy) {
if ($reviewType !== REVIEW_PC || $requestedBy !== $this->contactId) {
$this->self_assigned = false;
} else if ($this->reviewType === 0) {
$this->self_assigned = true;
}

$this->reviewType = max($reviewType, $this->reviewType);
$this->reviewSubmitted = max($reviewSubmitted, $this->reviewSubmitted);
$this->reviewRound = $reviewRound;

if ($reviewType > 0) {
if ($reviewSubmitted > 0 || $reviewNeedsSubmit === 0) {
* @param int $reviewRound */
private function mark_review_type($conf, $rflags,
$reviewNeedsSubmit, $reviewRound) {
$this->rflags |= $rflags;

if (($rflags & ReviewInfo::RF_TYPEMASK) !== 0) {
$this->reviewType = max(ReviewInfo::rflags_type($rflags), $this->reviewType);
$this->reviewRound = $reviewRound;

if (($rflags & ReviewInfo::RF_SUBMITTED) !== 0
|| $reviewNeedsSubmit === 0) {
$this->review_status = self::CIRS_SUBMITTED;
} else if ($this->review_status === 0) {
$this->review_status = self::CIRS_UNSUBMITTED;
Expand All @@ -194,17 +195,16 @@ private function mark_review_type($conf, $reviewType,
}

function mark_review(ReviewInfo $rrow) {
$this->mark_review_type($rrow->conf, $rrow->reviewType,
(int) $rrow->reviewSubmitted, $rrow->reviewNeedsSubmit, $rrow->reviewRound,
$rrow->requestedBy);
$this->mark_review_type($rrow->conf, $rrow->rflags,
$rrow->reviewNeedsSubmit, $rrow->reviewRound);
}

/** @param ?string $sig */
private function mark_my_review_permissions($conf, $sig) {
if ((string) $sig !== "") {
foreach (explode(",", $sig) as $r) {
$a = explode(" ", $r);
$this->mark_review_type($conf, (int) $a[0], (int) $a[1], (int) $a[2], (int) $a[3], (int) $a[4]);
$this->mark_review_type($conf, (int) $a[0], (int) $a[1], (int) $a[2]);
}
}
}
Expand Down Expand Up @@ -250,7 +250,7 @@ static function load_into(PaperInfo $prow, $user) {
}
// two queries is marginally faster than one union query
$mresult = Dbl::multi_qe($prow->conf->dblink, "select paperId, contactId, conflictType from PaperConflict where paperId?a and contactId?a;
select paperId, contactId, null, reviewType, reviewSubmitted, reviewNeedsSubmit, reviewRound, requestedBy from PaperReview where paperId?a and {$prwhere}",
select paperId, contactId, null, rflags, reviewNeedsSubmit, reviewRound from PaperReview where paperId?a and {$prwhere}",
$row_set->paper_ids(), array_keys($user_set),
$row_set->paper_ids(), array_keys($user_set), ...$qv);
while (($result = $mresult->next())) {
Expand All @@ -260,7 +260,7 @@ static function load_into(PaperInfo $prow, $user) {
if ($x[2] !== null) {
$ci->mark_conflict((int) $x[2]);
} else {
$ci->mark_review_type($pr->conf, (int) $x[3], (int) $x[4], (int) $x[5], (int) $x[6], (int) $x[7]);
$ci->mark_review_type($pr->conf, (int) $x[3], (int) $x[4], (int) $x[5]);
}
}
$result->close();
Expand Down Expand Up @@ -812,7 +812,8 @@ static function make_permissive_reviewer(Contact $user, $rtype, $tags) {
$prow->outcome = 1;
$prow->outcome_sign = 1;
$prow->conflictType = "0";
$prow->myReviewPermissions = "{$rtype} 1 0 0 -1";
$rf = ReviewInfo::RF_LIVE | (1 << $rtype) | ReviewInfo::RF_ACCEPTED | ReviewInfo::RF_DRAFTED | ReviewInfo::RF_SUBMITTED;
$prow->myReviewPermissions = "{$rf} 0 0";
$prow->_row_set->add_paper($prow);
$prow->myContactXid = $user->contactXid;
$prow->_rights_version = Contact::$rights_version;
Expand All @@ -828,7 +829,7 @@ function reload() {
/** @param string $prefix
* @return string */
static function my_review_permissions_sql($prefix = "") {
return "group_concat({$prefix}reviewType, ' ', coalesce({$prefix}reviewSubmitted,0), ' ', {$prefix}reviewNeedsSubmit, ' ', {$prefix}reviewRound, ' ', {$prefix}requestedBy)";
return "group_concat({$prefix}rflags, ' ', {$prefix}reviewNeedsSubmit, ' ', {$prefix}reviewRound)";
}

/** @return PermissionProblem */
Expand Down
2 changes: 1 addition & 1 deletion test/t_reviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ function test_self_assign() {
xassert_eqq($rrow->requestedBy, $this->u_lixia->contactId);
xassert_eqq($rrow->reviewType, REVIEW_PC);
xassert_neqq($rrow->rflags & ReviewInfo::RF_SELF_ASSIGNED, 0);
xassert($prow->contact_info($this->u_lixia)->self_assigned);
xassert($prow->contact_info($this->u_lixia)->self_assigned());
}

function test_rflags_type() {
Expand Down

0 comments on commit 4d2aa24

Please sign in to comment.