1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01:00

Remove loadReleephBranch and loadReleephProject from ReleephRequest

Summary: Ref T3551. Ref T3549. Mostly unnecessary with modern calls.

Test Plan:
- Called `releeph.queryrequests`.
- Called `releeph.request`.
- Called `releephwork.getbranchcommitmessage`.
- Called `releephwork.getcommitmessage`.
- Called `releephwork.nextrequest`.
- Viewed and edited branches and requests.
- Made a comment on a request.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T3549, T3551

Differential Revision: https://secure.phabricator.com/D8820
This commit is contained in:
epriestley 2014-04-20 11:54:58 -07:00
parent a4f975ef3e
commit d75d0acba5
11 changed files with 60 additions and 71 deletions

View file

@ -45,10 +45,8 @@ final class ConduitAPI_releeph_queryrequests_Method
$releephRequests = $query->execute();
foreach ($releephRequests as $releephRequest) {
$branch = $releephRequest->loadReleephBranch();
if (!$branch) {
continue;
}
$branch = $releephRequest->getBranch();
$request_commit_phid = $releephRequest->getRequestCommitPHID();
$revisionPHID =
$query->getRevisionPHID($request_commit_phid);

View file

@ -10,7 +10,7 @@ final class ConduitAPI_releeph_request_Method
public function defineParamTypes() {
return array(
'branchPHID' => 'required string',
'things' => 'required string',
'things' => 'required list<string>',
'fields' => 'dict<string, string>',
);
}
@ -35,15 +35,17 @@ final class ConduitAPI_releeph_request_Method
->executeOne();
$branch_phid = $request->getValue('branchPHID');
$releeph_branch = id(new ReleephBranch())
->loadOneWhere('phid = %s', $branch_phid);
$releeph_branch = id(new ReleephBranchQuery())
->setViewer($user)
->withPHIDs(array($branch_phid))
->executeOne();
if (!$releeph_branch) {
throw id(new ConduitException("ERR_BRANCH"))->setErrorDescription(
"No ReleephBranch found with PHID {$branch_phid}!");
}
$releeph_project = $releeph_branch->loadReleephProject();
$releeph_project = $releeph_branch->getProduct();
// Find the requested commit identifiers
$requested_commits = array();

View file

@ -26,10 +26,14 @@ final class ConduitAPI_releephwork_getbranchcommitmessage_Method
}
protected function execute(ConduitAPIRequest $request) {
$branch = id(new ReleephBranch())
->loadOneWhere('phid = %s', $request->getValue('branchPHID'));
$viewer = $request->getUser();
$project = $branch->loadReleephProject();
$branch = id(new ReleephBranchQuery())
->setViewer($viewer)
->withPHIDs(array($request->getValue('branchPHID')))
->executeOne();
$project = $branch->getProduct();
$creator_phid = $branch->getCreatedByUserPHID();
$cut_phid = $branch->getCutPointCommitPHID();

View file

@ -29,8 +29,12 @@ final class ConduitAPI_releephwork_getcommitmessage_Method
}
protected function execute(ConduitAPIRequest $request) {
$releeph_request = id(new ReleephRequest())
->loadOneWhere('phid = %s', $request->getValue('requestPHID'));
$viewer = $request->getUser();
$releeph_request = id(new ReleephRequestQuery())
->setViewer($viewer)
->withPHIDs(array($request->getValue('requestPHID')))
->executeOne();
$action = $request->getValue('action');
@ -38,8 +42,8 @@ final class ConduitAPI_releephwork_getcommitmessage_Method
$commit_message = array();
$project = $releeph_request->loadReleephProject();
$branch = $releeph_request->loadReleephBranch();
$branch = $releeph_request->getBranch();
$project = $branch->getProduct();
$selector = $project->getReleephFieldSelector();
$fields = $selector->getFieldSpecifications();

View file

@ -38,10 +38,12 @@ final class ConduitAPI_releephwork_nextrequest_Method
$viewer = $request->getUser();
$seen = $request->getValue('seen');
$branch = id(new ReleephBranch())
->loadOneWhere('phid = %s', $request->getValue('branchPHID'));
$branch = id(new ReleephBranchQuery())
->setViewer($viewer)
->withPHIDs(array($request->getValue('branchPHID')))
->executeOne();
$project = $branch->loadReleephProject();
$project = $branch->getProduct();
$needs_pick = array();
$needs_revert = array();

View file

@ -195,7 +195,7 @@ final class DifferentialReleephRequestFieldSpecification {
$rqs_seen = array();
$groups = array();
foreach ($releeph_requests as $releeph_request) {
$releeph_branch = $releeph_request->loadReleephBranch();
$releeph_branch = $releeph_request->getBranch();
$branch_name = $releeph_branch->getName();
$rq_id = 'RQ'.$releeph_request->getID();
@ -252,7 +252,7 @@ final class DifferentialReleephRequestFieldSpecification {
return;
}
$releeph_branch = head($releeph_requests)->loadReleephBranch();
$releeph_branch = head($releeph_requests)->getBranch();
if (!$this->isCommitOnBranch($repo, $commit, $releeph_branch)) {
return;
}
@ -297,10 +297,12 @@ final class DifferentialReleephRequestFieldSpecification {
private function loadReleephRequests() {
if (!$this->releephPHIDs) {
return array();
} else {
return id(new ReleephRequest())
->loadAllWhere('phid IN (%Ls)', $this->releephPHIDs);
}
return id(new ReleephRequestQuery())
->setViewer($this->getViewer())
->withPHIDs($this->releephPHIDs)
->execute();
}
private function isCommitOnBranch(PhabricatorRepository $repo,

View file

@ -204,8 +204,8 @@ final class ReleephRequestTransactionalEditor
protected function getMailTo(PhabricatorLiskDAO $object) {
$to_phids = array();
$releeph_project = $object->loadReleephProject();
foreach ($releeph_project->getPushers() as $phid) {
$product = $object->getBranch()->getProduct();
foreach ($product->getPushers() as $phid) {
$to_phids[] = $phid;
}
@ -227,8 +227,8 @@ final class ReleephRequestTransactionalEditor
$body = parent::buildMailBody($object, $xactions);
$rq = $object;
$releeph_branch = $rq->loadReleephBranch();
$releeph_project = $releeph_branch->loadReleephProject();
$releeph_branch = $rq->getBranch();
$releeph_project = $releeph_branch->getProduct();
/**
* If any of the events we are emailing about were about a pick failure

View file

@ -89,18 +89,6 @@ final class ReleephRequestQuery
public function willFilterPage(array $requests) {
// TODO: These should be serviced by the query, but are not currently
// denormalized anywhere. For now, filter them here instead.
$keep_status = array_fuse($this->getKeepStatusConstants());
if ($keep_status) {
foreach ($requests as $key => $request) {
if (empty($keep_status[$request->getStatus()])) {
unset($requests[$key]);
}
}
}
if ($this->severities) {
$severities = array_fuse($this->severities);
foreach ($requests as $key => $request) {
@ -133,6 +121,20 @@ final class ReleephRequestQuery
$request->attachBranch($branch);
}
// TODO: These should be serviced by the query, but are not currently
// denormalized anywhere. For now, filter them here instead. Note that
// we must perform this filtering *after* querying and attaching branches,
// because request status depends on the product.
$keep_status = array_fuse($this->getKeepStatusConstants());
if ($keep_status) {
foreach ($requests as $key => $request) {
if (empty($keep_status[$request->getStatus()])) {
unset($requests[$key]);
}
}
}
return $requests;
}

View file

@ -94,21 +94,13 @@ final class ReleephBranch extends ReleephDAO
public function getURI($path = null) {
$components = array(
'/releeph',
rawurlencode($this->loadReleephProject()->getName()),
rawurlencode($this->getBasename()),
$path
'/releeph/branch',
$this->getID(),
$path,
);
return implode('/', $components);
}
public function loadReleephProject() {
return $this->loadOneRelative(
new ReleephProject(),
'id',
'getReleephProjectID');
}
public function isActive() {
return $this->getIsActive();
}

View file

@ -42,7 +42,7 @@ final class ReleephProject extends ReleephDAO
public function getURI($path = null) {
$components = array(
'/releeph/project',
'/releeph/product',
$this->getID(),
$path
);

View file

@ -52,18 +52,15 @@ final class ReleephRequest extends ReleephDAO
* passes on this request.
*/
public function getPusherIntent() {
$project = $this->loadReleephProject();
if (!$project) {
return null;
}
$product = $this->getBranch()->getProduct();
if (!$project->getPushers()) {
if (!$product->getPushers()) {
return self::INTENT_WANT;
}
$found_pusher_want = false;
foreach ($this->userIntents as $phid => $intent) {
if ($project->isAuthoritativePHID($phid)) {
if ($product->isAuthoritativePHID($phid)) {
if ($intent == self::INTENT_PASS) {
return self::INTENT_PASS;
}
@ -210,20 +207,6 @@ final class ReleephRequest extends ReleephDAO
/* -( Loading external objects )------------------------------------------- */
public function loadReleephBranch() {
return $this->loadOneRelative(
new ReleephBranch(),
'id',
'getBranchID');
}
public function loadReleephProject() {
$branch = $this->loadReleephBranch();
if ($branch) {
return $branch->loadReleephProject();
}
}
public function loadPhabricatorRepositoryCommit() {
return $this->loadOneRelative(
new PhabricatorRepositoryCommit(),