1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-29 16:08:22 +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
* 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);
/**
@ -95,8 +95,9 @@ final class ConduitAPI_releephwork_nextrequest_Method
} elseif ($needs_pick) {
$releeph_request = head($needs_pick);
$action = 'pick';
$commit_id = $releeph_request->getRequestCommitIdentifier();
$commit_phid = $releeph_request->getRequestCommitPHID();
$commit = $releeph_request->loadPhabricatorRepositoryCommit();
$commit_id = $commit->getCommitIdentifier();
$commit_phid = $commit->getPHID();
} else {
// Return early if there's nothing to do!
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
* the order in which they were picked to the branch.

View file

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

View file

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

View file

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

View file

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