mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
Continue converting Audit constants, allowing the Query to handle either strings or integers
Summary: Ref T13197. We're almost ready to migrate: let the Query accept either older integer values or new string values. Then move some callsites to use strings. Test Plan: Called `audit.query`, browsed audits, audited commits. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13197 Differential Revision: https://secure.phabricator.com/D19650
This commit is contained in:
parent
bae8a95114
commit
853a816b3c
6 changed files with 40 additions and 23 deletions
|
@ -68,17 +68,17 @@ final class AuditQueryConduitAPIMethod extends AuditConduitAPIMethod {
|
|||
|
||||
$status_map = array(
|
||||
self::AUDIT_LEGACYSTATUS_OPEN => array(
|
||||
PhabricatorAuditCommitStatusConstants::NEEDS_AUDIT,
|
||||
PhabricatorAuditCommitStatusConstants::CONCERN_RAISED,
|
||||
PhabricatorAuditCommitStatusConstants::MODERN_NEEDS_AUDIT,
|
||||
PhabricatorAuditCommitStatusConstants::MODERN_CONCERN_RAISED,
|
||||
),
|
||||
self::AUDIT_LEGACYSTATUS_CONCERN => array(
|
||||
PhabricatorAuditCommitStatusConstants::CONCERN_RAISED,
|
||||
PhabricatorAuditCommitStatusConstants::MODERN_CONCERN_RAISED,
|
||||
),
|
||||
self::AUDIT_LEGACYSTATUS_ACCEPTED => array(
|
||||
PhabricatorAuditCommitStatusConstants::FULLY_AUDITED,
|
||||
PhabricatorAuditCommitStatusConstants::MODERN_AUDITED,
|
||||
),
|
||||
self::AUDIT_LEGACYSTATUS_PARTIAL => array(
|
||||
PhabricatorAuditCommitStatusConstants::PARTIALLY_AUDITED,
|
||||
PhabricatorAuditCommitStatusConstants::MODERN_PARTIALLY_AUDITED,
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
@ -22,9 +22,11 @@ final class PhabricatorAuditCommitStatusConstants extends Phobject {
|
|||
public static function newForLegacyStatus($status) {
|
||||
$map = self::getMap();
|
||||
|
||||
foreach ($map as $key => $spec) {
|
||||
if (idx($spec, 'legacy') == $status) {
|
||||
return self::newForStatus($key);
|
||||
if (is_int($status) || ctype_digit($status)) {
|
||||
foreach ($map as $key => $spec) {
|
||||
if ((int)idx($spec, 'legacy') === (int)$status) {
|
||||
return self::newForStatus($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,6 +58,10 @@ final class PhabricatorAuditCommitStatusConstants extends Phobject {
|
|||
return idx($this->spec, 'color');
|
||||
}
|
||||
|
||||
public function getLegacyKey() {
|
||||
return idx($this->spec, 'legacy');
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return idx($this->spec, 'name', pht('Unknown ("%s")', $this->key));
|
||||
}
|
||||
|
@ -64,6 +70,10 @@ final class PhabricatorAuditCommitStatusConstants extends Phobject {
|
|||
return ($this->key == self::MODERN_NONE);
|
||||
}
|
||||
|
||||
public function isNeedsAudit() {
|
||||
return ($this->key == self::MODERN_NEEDS_AUDIT);
|
||||
}
|
||||
|
||||
public function isConcernRaised() {
|
||||
return ($this->key == self::MODERN_CONCERN_RAISED);
|
||||
}
|
||||
|
|
|
@ -714,10 +714,17 @@ final class DiffusionCommitQuery
|
|||
}
|
||||
|
||||
if ($this->statuses !== null) {
|
||||
$statuses = array();
|
||||
foreach ($this->statuses as $status) {
|
||||
$object = PhabricatorAuditCommitStatusConstants::newForLegacyStatus(
|
||||
$status);
|
||||
$statuses[] = $object->getLegacyKey();
|
||||
}
|
||||
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'commit.auditStatus IN (%Ld)',
|
||||
$this->statuses);
|
||||
$statuses);
|
||||
}
|
||||
|
||||
if ($this->packagePHIDs !== null) {
|
||||
|
|
|
@ -164,15 +164,13 @@ final class DiffusionCommitRequiredActionResultBucket
|
|||
$results = array();
|
||||
$objects = $this->objects;
|
||||
|
||||
$status_waiting = array(
|
||||
PhabricatorAuditCommitStatusConstants::NEEDS_AUDIT,
|
||||
PhabricatorAuditCommitStatusConstants::NEEDS_VERIFICATION,
|
||||
PhabricatorAuditCommitStatusConstants::PARTIALLY_AUDITED,
|
||||
);
|
||||
$status_waiting = array_fuse($status_waiting);
|
||||
|
||||
foreach ($objects as $key => $object) {
|
||||
if (empty($status_waiting[$object->getAuditStatus()])) {
|
||||
$any_waiting =
|
||||
$object->isAuditStatusNeedsAudit() ||
|
||||
$object->isAuditStatusNeedsVerification() ||
|
||||
$object->isAuditStatusPartiallyAudited();
|
||||
|
||||
if (!$any_waiting) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,8 @@ final class PhabricatorOwnersDetailController
|
|||
'package' => $package->getPHID(),
|
||||
));
|
||||
|
||||
$status_concern = PhabricatorAuditCommitStatusConstants::CONCERN_RAISED;
|
||||
$status_concern =
|
||||
PhabricatorAuditCommitStatusConstants::MODERN_CONCERN_RAISED;
|
||||
|
||||
$attention_commits = id(new DiffusionCommitQuery())
|
||||
->setViewer($request->getUser())
|
||||
|
|
|
@ -381,14 +381,11 @@ final class PhabricatorRepositoryCommit
|
|||
}
|
||||
}
|
||||
|
||||
$current_status = $this->getAuditStatus();
|
||||
$status_verify = PhabricatorAuditCommitStatusConstants::NEEDS_VERIFICATION;
|
||||
|
||||
if ($any_concern) {
|
||||
if ($current_status == $status_verify) {
|
||||
if ($this->isAuditStatusNeedsVerification()) {
|
||||
// If the change is in "Needs Verification", we keep it there as
|
||||
// long as any auditors still have concerns.
|
||||
$status = $status_verify;
|
||||
$status = PhabricatorAuditCommitStatusConstants::NEEDS_VERIFICATION;
|
||||
} else {
|
||||
$status = PhabricatorAuditCommitStatusConstants::CONCERN_RAISED;
|
||||
}
|
||||
|
@ -539,6 +536,10 @@ final class PhabricatorRepositoryCommit
|
|||
return $this->getAuditStatusObject()->isNoAudit();
|
||||
}
|
||||
|
||||
public function isAuditStatusNeedsAudit() {
|
||||
return $this->getAuditStatusObject()->isNeedsAudit();
|
||||
}
|
||||
|
||||
public function isAuditStatusConcernRaised() {
|
||||
return $this->getAuditStatusObject()->isConcernRaised();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue