1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +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:
epriestley 2012-02-27 09:51:00 -08:00
parent 053d576ad6
commit 25fade5008
5 changed files with 23 additions and 4 deletions

View file

@ -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;

View file

@ -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');

View file

@ -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(

View file

@ -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);
}
}

View file

@ -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');