mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 09:20:58 +01:00
Proper indexing for Differential revisions.
Summary: Test Plan: Reviewers: CC:
This commit is contained in:
parent
c5c31d7eb9
commit
2aece70eaf
3 changed files with 62 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue