2015-12-21 09:02:55 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialRevisionFulltextEngine
|
|
|
|
extends PhabricatorFulltextEngine {
|
|
|
|
|
|
|
|
protected function buildAbstractDocument(
|
|
|
|
PhabricatorSearchAbstractDocument $document,
|
|
|
|
$object) {
|
|
|
|
|
|
|
|
$revision = id(new DifferentialRevisionQuery())
|
|
|
|
->setViewer($this->getViewer())
|
|
|
|
->withPHIDs(array($object->getPHID()))
|
2017-03-20 14:37:24 -07:00
|
|
|
->needReviewers(true)
|
2015-12-21 09:02:55 -08:00
|
|
|
->executeOne();
|
|
|
|
|
|
|
|
// TODO: This isn't very clean, but custom fields currently rely on it.
|
2017-03-20 15:04:23 -07:00
|
|
|
$object->attachReviewers($revision->getReviewers());
|
2015-12-21 09:02:55 -08:00
|
|
|
|
|
|
|
$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).
|
2017-08-04 05:29:49 -07:00
|
|
|
if ($revision->isNeedsReview()) {
|
2017-03-20 15:04:23 -07:00
|
|
|
$reviewers = $revision->getReviewerPHIDs();
|
|
|
|
$reviewers = array_fuse($reviewers);
|
|
|
|
|
2015-12-21 09:02:55 -08:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|