1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-03 18:38:27 +01:00
phorge-phorge/src/applications/differential/search/DifferentialRevisionFulltextEngine.php
epriestley 2e36653965 Reduce callsites to "ArcanistDifferentialRevisionStatus" in Phabricator
Summary:
Ref T2543. These are currently numeric values, like "0" and "3". I want to replace them with strings, like "accepted", and move definitions from Arcanist to Phabricator.

To set the stage for this, reduce the number of callsites where Phabricator invokes `ArcanistDifferentialRevisionStatus`.

This is just the easy ones. I'll hold this until the release cut.

Test Plan:
- Called `differential.find`.
- Called `differential.getrevision`.
- Called `differential.query`.
- Removed all reviewers from a revision, saw warning.
- Abandoned the no-reviewers revision, no more warning.
- Attached a revision to a task to get it to show the state icon with the status on a tooltip.
- Viewed revision bucketing on dashboard.
- Used `bin/search index` to reindex a revision.
- Hit the "Land Revision" endpoint.

I didn't explicitly test these cases:

  - Doorkeeper Asana integration, since setup takes a thousand years.
  - Disambiguation logic when multiple hashes match, since setup is also very involved.
  - Releeph because it's Releeph.

Reviewers: chad

Reviewed By: chad

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T2543

Differential Revision: https://secure.phabricator.com/D18339
2017-08-09 11:04:52 -07:00

64 lines
2.1 KiB
PHP

<?php
final class DifferentialRevisionFulltextEngine
extends PhabricatorFulltextEngine {
protected function buildAbstractDocument(
PhabricatorSearchAbstractDocument $document,
$object) {
$revision = id(new DifferentialRevisionQuery())
->setViewer($this->getViewer())
->withPHIDs(array($object->getPHID()))
->needReviewers(true)
->executeOne();
// TODO: This isn't very clean, but custom fields currently rely on it.
$object->attachReviewers($revision->getReviewers());
$document->setDocumentTitle($revision->getTitle());
$document->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
$revision->getAuthorPHID(),
PhabricatorPeopleUserPHIDType::TYPECONST,
$revision->getDateCreated());
$document->addRelationship(
$revision->isClosed()
? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED
: PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
$revision->getPHID(),
DifferentialRevisionPHIDType::TYPECONST,
PhabricatorTime::getNow());
// If a revision needs review, the owners are the reviewers. Otherwise, the
// owner is the author (e.g., accepted, rejected, closed).
if ($revision->isNeedsReview()) {
$reviewers = $revision->getReviewerPHIDs();
$reviewers = array_fuse($reviewers);
if ($reviewers) {
foreach ($reviewers as $phid) {
$document->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
$phid,
PhabricatorPeopleUserPHIDType::TYPECONST,
$revision->getDateModified()); // Bogus timestamp.
}
} else {
$document->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_UNOWNED,
$revision->getPHID(),
PhabricatorPeopleUserPHIDType::TYPECONST,
$revision->getDateModified()); // Bogus timestamp.
}
} else {
$document->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
$revision->getAuthorPHID(),
PhabricatorPHIDConstants::PHID_TYPE_VOID,
$revision->getDateCreated());
}
}
}