1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-30 16:38:21 +01:00

Simplify ReleephRequest schema

Summary:
Removing a bunch of cache-style columns from `ReleephRequest`, where it's actually much easier to just load the information at runtime.

This makes sense for migrating to `PhabricatorApplicationTransactions`, where each xaction changes one aspect of a `ReleephRequest` at a time (rather than multiple columns at once.)

Test Plan: Request something, run `arc releeph` and watch the picks, pass on some RQs, run `arc releeph` and watch the reverts.

Reviewers: wez, epriestley

Reviewed By: epriestley

CC: epriestley, aran

Maniphest Tasks: T2720

Differential Revision: https://secure.phabricator.com/D5851
This commit is contained in:
Edward Speyer 2013-04-12 00:54:51 +01:00
parent 19aec33198
commit 5b2fc6a184
6 changed files with 34 additions and 17 deletions

View file

@ -0,0 +1,8 @@
ALTER TABLE {$NAMESPACE}_releeph.releeph_request
DROP COLUMN requestCommitIdentifier,
DROP COLUMN requestCommitOrdinal,
DROP COLUMN status,
DROP COLUMN committedByUserPHID,
DROP KEY `requestIdentifierBranch`,
ADD CONSTRAINT
UNIQUE KEY `requestIdentifierBranch` (`requestCommitPHID`, `branchID`);

View file

@ -71,7 +71,7 @@ final class ConduitAPI_releephwork_nextrequest_Method
* This is easy for $needs_pick as the ordinal is stored. It is hard for * This is easy for $needs_pick as the ordinal is stored. It is hard for
* reverts, as we have to look that information up. * reverts, as we have to look that information up.
*/ */
$needs_pick = msort($needs_pick, 'getRequestCommitOrdinal'); $needs_pick = $this->sortPicks($needs_pick);
$needs_revert = $this->sortReverts($needs_revert); $needs_revert = $this->sortReverts($needs_revert);
/** /**
@ -95,8 +95,9 @@ final class ConduitAPI_releephwork_nextrequest_Method
} elseif ($needs_pick) { } elseif ($needs_pick) {
$releeph_request = head($needs_pick); $releeph_request = head($needs_pick);
$action = 'pick'; $action = 'pick';
$commit_id = $releeph_request->getRequestCommitIdentifier(); $commit = $releeph_request->loadPhabricatorRepositoryCommit();
$commit_phid = $releeph_request->getRequestCommitPHID(); $commit_id = $commit->getCommitIdentifier();
$commit_phid = $commit->getPHID();
} else { } else {
// Return early if there's nothing to do! // Return early if there's nothing to do!
return array(); return array();
@ -165,6 +166,18 @@ final class ConduitAPI_releephwork_nextrequest_Method
); );
} }
private function sortPicks(array $releeph_requests) {
$surrogate = array();
foreach ($releeph_requests as $rq) {
// TODO: it's likely that relying on the `id` column to provide
// trunk-commit-order is thoroughly broken.
$ordinal = (int) $rq->loadPhabricatorRepositoryCommit()->getID();
$surrogate[$ordinal] = $rq;
}
ksort($surrogate);
return $surrogate;
}
/** /**
* Sort an array of ReleephRequests, that have been picked into a branch, in * Sort an array of ReleephRequests, that have been picked into a branch, in
* the order in which they were picked to the branch. * the order in which they were picked to the branch.

View file

@ -14,7 +14,6 @@ final class ReleephRequestEditController extends ReleephController {
$phids = array(); $phids = array();
$phids[] = $releeph_request->getRequestCommitPHID(); $phids[] = $releeph_request->getRequestCommitPHID();
$phids[] = $releeph_request->getRequestUserPHID(); $phids[] = $releeph_request->getRequestUserPHID();
$phids[] = $releeph_request->getCommittedByUserPHID();
$handles = id(new PhabricatorObjectHandleData($phids)) $handles = id(new PhabricatorObjectHandleData($phids))
->setViewer($request->getUser()) ->setViewer($request->getUser())

View file

@ -44,9 +44,7 @@ final class ReleephRequestEditor extends PhabricatorEditor {
$rq $rq
->setBranchID($branch->getID()) ->setBranchID($branch->getID())
->setRequestCommitIdentifier($commit->getCommitIdentifier())
->setRequestCommitPHID($commit->getPHID()) ->setRequestCommitPHID($commit->getPHID())
->setRequestCommitOrdinal($commit->getID())
->setInBranch(0) ->setInBranch(0)
->setRequestUserPHID($requestor->getPHID()) ->setRequestUserPHID($requestor->getPHID())
->setUserIntent($requestor, ReleephRequest::INTENT_WANT) ->setUserIntent($requestor, ReleephRequest::INTENT_WANT)
@ -177,7 +175,6 @@ final class ReleephRequestEditor extends PhabricatorEditor {
->setPickStatus(ReleephRequest::PICK_OK) ->setPickStatus(ReleephRequest::PICK_OK)
->setCommitIdentifier($new_commit_id) ->setCommitIdentifier($new_commit_id)
->setCommitPHID(null) ->setCommitPHID(null)
->setCommittedByUserPHID($actor->getPHID())
->save(); ->save();
break; break;
@ -187,7 +184,6 @@ final class ReleephRequestEditor extends PhabricatorEditor {
->setPickStatus(ReleephRequest::REVERT_OK) ->setPickStatus(ReleephRequest::REVERT_OK)
->setCommitIdentifier(null) ->setCommitIdentifier(null)
->setCommitPHID(null) ->setCommitPHID(null)
->setCommittedByUserPHID(null)
->save(); ->save();
break; break;
@ -254,7 +250,6 @@ final class ReleephRequestEditor extends PhabricatorEditor {
->setPickStatus(ReleephRequest::PICK_OK) ->setPickStatus(ReleephRequest::PICK_OK)
->setCommitIdentifier($commit->getCommitIdentifier()) ->setCommitIdentifier($commit->getCommitIdentifier())
->setCommitPHID($commit->getPHID()) ->setCommitPHID($commit->getPHID())
->setCommittedByUserPHID($actor->getPHID())
->save(); ->save();
break; break;
@ -264,7 +259,6 @@ final class ReleephRequestEditor extends PhabricatorEditor {
->setPickStatus(ReleephRequest::REVERT_OK) ->setPickStatus(ReleephRequest::REVERT_OK)
->setCommitIdentifier(null) ->setCommitIdentifier(null)
->setCommitPHID(null) ->setCommitPHID(null)
->setCommittedByUserPHID(null)
->save(); ->save();
break; break;

View file

@ -11,13 +11,10 @@ final class ReleephRequest extends ReleephDAO {
protected $pickStatus; protected $pickStatus;
// Information about the thing being requested // Information about the thing being requested
protected $requestCommitIdentifier;
protected $requestCommitPHID; protected $requestCommitPHID;
protected $requestCommitOrdinal;
// Information about the last commit to the releeph branch // Information about the last commit to the releeph branch
protected $commitIdentifier; protected $commitIdentifier;
protected $committedByUserPHID;
protected $commitPHID; protected $commitPHID;
// Pre-populated handles that we'll bulk load in ReleephBranch // Pre-populated handles that we'll bulk load in ReleephBranch
@ -267,10 +264,12 @@ final class ReleephRequest extends ReleephDAO {
} }
public function loadPhabricatorRepositoryCommitData() { public function loadPhabricatorRepositoryCommitData() {
return $this->loadOneRelative( $commit = $this->loadPhabricatorRepositoryCommit();
new PhabricatorRepositoryCommitData(), if ($commit) {
'commitID', return $commit->loadOneRelative(
'getRequestCommitOrdinal'); new PhabricatorRepositoryCommitData(),
'commitID');
}
} }
public function loadDifferentialRevision() { public function loadDifferentialRevision() {

View file

@ -1270,6 +1270,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
'type' => 'sql', 'type' => 'sql',
'name' => $this->getPatchPath('20130502.countdownrevamp3.sql'), 'name' => $this->getPatchPath('20130502.countdownrevamp3.sql'),
), ),
'20130507.releephrqsimplifycols.sql' => array(
'type' => 'sql',
'name' => $this->getPatchPath('20130507.releephrqsimplifycols.sql'),
),
); );
} }
} }