From 25fade50089005bc91b05d100b6247b90c6b220a Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 27 Feb 2012 09:51:00 -0800 Subject: [PATCH] Add audits to search Summary: Add audit information to the commit search index. Test Plan: Updated a commit, searched for terms in its comments, got hits. Reviewers: btrahan, jungejason Reviewed By: jungejason CC: aran, epriestley Maniphest Tasks: T904 Differential Revision: https://secure.phabricator.com/D1696 --- .../comment/PhabricatorAuditCommentEditor.php | 7 +++++-- src/applications/audit/editor/comment/__init__.php | 1 + .../PhabricatorRepositoryCommitHeraldWorker.php | 5 ++++- .../repository/PhabricatorSearchCommitIndexer.php | 13 ++++++++++++- .../search/index/indexer/repository/__init__.php | 1 + 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/applications/audit/editor/comment/PhabricatorAuditCommentEditor.php b/src/applications/audit/editor/comment/PhabricatorAuditCommentEditor.php index 29ffd6b926..27db026dbe 100644 --- a/src/applications/audit/editor/comment/PhabricatorAuditCommentEditor.php +++ b/src/applications/audit/editor/comment/PhabricatorAuditCommentEditor.php @@ -72,8 +72,8 @@ final class PhabricatorAuditCommentEditor { } $this->publishFeedStory($comment, array_keys($audit_phids)); + PhabricatorSearchCommitIndexer::indexCommit($commit); - // TODO: Search index. // TODO: Email. } @@ -113,7 +113,10 @@ final class PhabricatorAuditCommentEditor { return array_keys($phids); } - private function publishFeedStory($comment, array $more_phids) { + private function publishFeedStory( + PhabricatorAuditComment $comment, + array $more_phids) { + $commit = $this->commit; $user = $this->user; diff --git a/src/applications/audit/editor/comment/__init__.php b/src/applications/audit/editor/comment/__init__.php index f362087b9f..e85ccf3cd2 100644 --- a/src/applications/audit/editor/comment/__init__.php +++ b/src/applications/audit/editor/comment/__init__.php @@ -13,6 +13,7 @@ phutil_require_module('phabricator', 'applications/owners/storage/owner'); phutil_require_module('phabricator', 'applications/owners/storage/package'); phutil_require_module('phabricator', 'applications/owners/storage/packagecommitrelationship'); phutil_require_module('phabricator', 'applications/project/query/project'); +phutil_require_module('phabricator', 'applications/search/index/indexer/repository'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php b/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php index 938a6a0641..1d2e23a71b 100644 --- a/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php +++ b/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php @@ -144,7 +144,10 @@ EOBODY; $mailer->saveAndSend(); } - private function createAudits($commit, $map, $rules) { + private function createAudits( + PhabricatorRepositoryCommit $commit, + array $map, + array $rules) { $table = new PhabricatorOwnersPackageCommitRelationship(); $rships = $table->loadAllWhere( diff --git a/src/applications/search/index/indexer/repository/PhabricatorSearchCommitIndexer.php b/src/applications/search/index/indexer/repository/PhabricatorSearchCommitIndexer.php index 6a5cdb42b4..a3ad51fa49 100644 --- a/src/applications/search/index/indexer/repository/PhabricatorSearchCommitIndexer.php +++ b/src/applications/search/index/indexer/repository/PhabricatorSearchCommitIndexer.php @@ -1,7 +1,7 @@ loadAllWhere( + 'targetPHID = %s', + $commit->getPHID()); + foreach ($comments as $comment) { + if (strlen($comment->getContent())) { + $doc->addField( + PhabricatorSearchField::FIELD_COMMENT, + $comment->getContent()); + } + } + self::reindexAbstractDocument($doc); } } diff --git a/src/applications/search/index/indexer/repository/__init__.php b/src/applications/search/index/indexer/repository/__init__.php index 9d0b8d2e14..b87c763192 100644 --- a/src/applications/search/index/indexer/repository/__init__.php +++ b/src/applications/search/index/indexer/repository/__init__.php @@ -6,6 +6,7 @@ +phutil_require_module('phabricator', 'applications/audit/storage/auditcomment'); phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/repository/storage/commitdata'); phutil_require_module('phabricator', 'applications/repository/storage/repository');