diff --git a/src/applications/search/index/indexer/differential/PhabricatorSearchDifferentialIndexer.php b/src/applications/search/index/indexer/differential/PhabricatorSearchDifferentialIndexer.php index 5ad13064a1..8e0af71606 100644 --- a/src/applications/search/index/indexer/differential/PhabricatorSearchDifferentialIndexer.php +++ b/src/applications/search/index/indexer/differential/PhabricatorSearchDifferentialIndexer.php @@ -40,6 +40,63 @@ class PhabricatorSearchDifferentialIndexer 'USER', $rev->getDateCreated()); + if ($rev->getStatus() != DifferentialRevisionStatus::COMMITTED && + $rev->getStatus() != DifferentialRevisionStatus::ABANDONED) { + $doc->addRelationship( + PhabricatorSearchRelationship::RELATIONSHIP_OPEN, + $rev->getPHID(), + 'DREV', + time()); + } + + $comments = id(new DifferentialInlineComment())->loadAllWhere( + 'revisionID = %d AND commentID is not null', + $rev->getID()); + + $touches = array(); + + foreach ($comments as $comment) { + if (strlen($comment->getContent())) { + // TODO: we should also index inline comments. + $doc->addField( + PhabricatorSearchField::FIELD_COMMENT, + $comment->getContent()); + } + + $author = $comment->getAuthorPHID(); + $touches[$author] = $comment->getDateCreated(); + } + + foreach ($touches as $touch => $time) { + $doc->addRelationship( + PhabricatorSearchRelationship::RELATIONSHIP_TOUCH, + $touch, + 'USER', + $time); + } + + $rev->loadRelationships(); + + foreach ($rev->getReviewers() as $phid) { + $doc->addRelationship( + PhabricatorSearchRelationship::RELATIONSHIP_OWNER, + $phid, + 'USER', + $rev->getDateModified()); // Bogus timestamp. + } + + $ccphids = $rev->getCCPHIDs(); + $handles = id(new PhabricatorObjectHandleData($ccphids)) + ->loadHandles(); + + foreach ($handles as $phid => $handle) { + $doc->addRelationship( + PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER, + $phid, + $handle->getType(), + $rev->getDateModified()); // Bogus timestamp. + } + PhabricatorSearchDocument::reindexAbstractDocument($doc); } } diff --git a/src/applications/search/index/indexer/differential/__init__.php b/src/applications/search/index/indexer/differential/__init__.php index ba69035939..9dda223db2 100644 --- a/src/applications/search/index/indexer/differential/__init__.php +++ b/src/applications/search/index/indexer/differential/__init__.php @@ -6,11 +6,16 @@ +phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus'); +phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment'); +phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/search/constants/field'); phutil_require_module('phabricator', 'applications/search/constants/relationship'); phutil_require_module('phabricator', 'applications/search/index/abstractdocument'); phutil_require_module('phabricator', 'applications/search/index/indexer/base'); phutil_require_module('phabricator', 'applications/search/storage/document/document'); +phutil_require_module('phutil', 'utils'); + phutil_require_source('PhabricatorSearchDifferentialIndexer.php'); diff --git a/src/applications/search/index/indexer/maniphest/PhabricatorSearchManiphestIndexer.php b/src/applications/search/index/indexer/maniphest/PhabricatorSearchManiphestIndexer.php index 7fe489e5af..c548b39263 100644 --- a/src/applications/search/index/indexer/maniphest/PhabricatorSearchManiphestIndexer.php +++ b/src/applications/search/index/indexer/maniphest/PhabricatorSearchManiphestIndexer.php @@ -76,10 +76,6 @@ class PhabricatorSearchManiphestIndexer if (in_array($added_cc, $current_ccs)) { if (empty($ccs[$added_cc])) { $ccs[$added_cc] = $transaction->getDateCreated(); - - // CCs count as touches, even if you didn't technically - // interact with the object directly. - $touches[$added_cc] = $transaction->getDateCreated(); } } }