Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/search/DifferentialSearchIndexer.php
Show All 18 Lines | protected function loadDocumentByPHID($phid) { | ||||
return $object; | return $object; | ||||
} | } | ||||
protected function buildAbstractDocumentByPHID($phid) { | protected function buildAbstractDocumentByPHID($phid) { | ||||
$rev = $this->loadDocumentByPHID($phid); | $rev = $this->loadDocumentByPHID($phid); | ||||
$doc = new PhabricatorSearchAbstractDocument(); | $doc = new PhabricatorSearchAbstractDocument(); | ||||
$doc->setPHID($rev->getPHID()); | $doc->setPHID($rev->getPHID()); | ||||
$doc->setDocumentType(DifferentialPHIDTypeRevision::TYPECONST); | $doc->setDocumentType(DifferentialRevisionPHIDType::TYPECONST); | ||||
$doc->setDocumentTitle($rev->getTitle()); | $doc->setDocumentTitle($rev->getTitle()); | ||||
$doc->setDocumentCreated($rev->getDateCreated()); | $doc->setDocumentCreated($rev->getDateCreated()); | ||||
$doc->setDocumentModified($rev->getDateModified()); | $doc->setDocumentModified($rev->getDateModified()); | ||||
$doc->addRelationship( | $doc->addRelationship( | ||||
PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, | PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, | ||||
$rev->getAuthorPHID(), | $rev->getAuthorPHID(), | ||||
PhabricatorPeoplePHIDTypeUser::TYPECONST, | PhabricatorPeopleUserPHIDType::TYPECONST, | ||||
$rev->getDateCreated()); | $rev->getDateCreated()); | ||||
$doc->addRelationship( | $doc->addRelationship( | ||||
$rev->isClosed() | $rev->isClosed() | ||||
? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED | ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED | ||||
: PhabricatorSearchRelationship::RELATIONSHIP_OPEN, | : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, | ||||
$rev->getPHID(), | $rev->getPHID(), | ||||
DifferentialPHIDTypeRevision::TYPECONST, | DifferentialRevisionPHIDType::TYPECONST, | ||||
time()); | time()); | ||||
$this->indexTransactions( | $this->indexTransactions( | ||||
$doc, | $doc, | ||||
new DifferentialTransactionQuery(), | new DifferentialTransactionQuery(), | ||||
array($rev->getPHID())); | array($rev->getPHID())); | ||||
// If a revision needs review, the owners are the reviewers. Otherwise, the | // If a revision needs review, the owners are the reviewers. Otherwise, the | ||||
// owner is the author (e.g., accepted, rejected, closed). | // owner is the author (e.g., accepted, rejected, closed). | ||||
if ($rev->getStatus() == ArcanistDifferentialRevisionStatus::NEEDS_REVIEW) { | if ($rev->getStatus() == ArcanistDifferentialRevisionStatus::NEEDS_REVIEW) { | ||||
$reviewers = $rev->getReviewerStatus(); | $reviewers = $rev->getReviewerStatus(); | ||||
$reviewers = mpull($reviewers, 'getReviewerPHID', 'getReviewerPHID'); | $reviewers = mpull($reviewers, 'getReviewerPHID', 'getReviewerPHID'); | ||||
if ($reviewers) { | if ($reviewers) { | ||||
foreach ($reviewers as $phid) { | foreach ($reviewers as $phid) { | ||||
$doc->addRelationship( | $doc->addRelationship( | ||||
PhabricatorSearchRelationship::RELATIONSHIP_OWNER, | PhabricatorSearchRelationship::RELATIONSHIP_OWNER, | ||||
$phid, | $phid, | ||||
PhabricatorPeoplePHIDTypeUser::TYPECONST, | PhabricatorPeopleUserPHIDType::TYPECONST, | ||||
$rev->getDateModified()); // Bogus timestamp. | $rev->getDateModified()); // Bogus timestamp. | ||||
} | } | ||||
} else { | } else { | ||||
$doc->addRelationship( | $doc->addRelationship( | ||||
PhabricatorSearchRelationship::RELATIONSHIP_UNOWNED, | PhabricatorSearchRelationship::RELATIONSHIP_UNOWNED, | ||||
$rev->getPHID(), | $rev->getPHID(), | ||||
PhabricatorPeoplePHIDTypeUser::TYPECONST, | PhabricatorPeopleUserPHIDType::TYPECONST, | ||||
$rev->getDateModified()); // Bogus timestamp. | $rev->getDateModified()); // Bogus timestamp. | ||||
} | } | ||||
} else { | } else { | ||||
$doc->addRelationship( | $doc->addRelationship( | ||||
PhabricatorSearchRelationship::RELATIONSHIP_OWNER, | PhabricatorSearchRelationship::RELATIONSHIP_OWNER, | ||||
$rev->getAuthorPHID(), | $rev->getAuthorPHID(), | ||||
PhabricatorPHIDConstants::PHID_TYPE_VOID, | PhabricatorPHIDConstants::PHID_TYPE_VOID, | ||||
$rev->getDateCreated()); | $rev->getDateCreated()); | ||||
} | } | ||||
return $doc; | return $doc; | ||||
} | } | ||||
} | } |