mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
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
This commit is contained in:
parent
053d576ad6
commit
25fade5008
5 changed files with 23 additions and 4 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -66,6 +66,17 @@ class PhabricatorSearchCommitIndexer
|
|||
PhabricatorPHIDConstants::PHID_TYPE_REPO,
|
||||
$date_created);
|
||||
|
||||
$comments = id(new PhabricatorAuditComment())->loadAllWhere(
|
||||
'targetPHID = %s',
|
||||
$commit->getPHID());
|
||||
foreach ($comments as $comment) {
|
||||
if (strlen($comment->getContent())) {
|
||||
$doc->addField(
|
||||
PhabricatorSearchField::FIELD_COMMENT,
|
||||
$comment->getContent());
|
||||
}
|
||||
}
|
||||
|
||||
self::reindexAbstractDocument($doc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue