Add support for differential field specifications to be indexed in search
Summary: ...and do so for a few fields -- summary, test plan, and revert plan. Test Plan: added NATASHA and BULLWINKLE to summary and test plan of existing diff. Diff showed up in search! Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T654 Differential Revision: https://secure.phabricator.com/D3915
This commit is contained in:
@@ -383,6 +383,31 @@ abstract class DifferentialFieldSpecification {
|
|||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -( Extending the Search Interface )------------------------------------ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @task search
|
||||||
|
*/
|
||||||
|
public function shouldAddToSearchIndex() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @task search
|
||||||
|
*/
|
||||||
|
public function getValueForSearchIndex() {
|
||||||
|
throw new DifferentialFieldSpecificationIncompleteException($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NOTE: Keys *must be* 4 characters for
|
||||||
|
* @{class:PhabricatorSearchEngineMySQL}.
|
||||||
|
*
|
||||||
|
* @task search
|
||||||
|
*/
|
||||||
|
public function getKeyForSearchIndex() {
|
||||||
|
throw new DifferentialFieldSpecificationIncompleteException($this);
|
||||||
|
}
|
||||||
|
|
||||||
/* -( Extending Commit Messages )------------------------------------------ */
|
/* -( Extending Commit Messages )------------------------------------------ */
|
||||||
|
|
||||||
|
|||||||
@@ -95,4 +95,16 @@ final class DifferentialRevertPlanFieldSpecification
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shouldAddToSearchIndex() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValueForSearchIndex() {
|
||||||
|
return $this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getKeyForSearchIndex() {
|
||||||
|
return 'rpln';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,4 +70,16 @@ final class DifferentialSummaryFieldSpecification
|
|||||||
return $this->summary;
|
return $this->summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shouldAddToSearchIndex() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValueForSearchIndex() {
|
||||||
|
return $this->summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getKeyForSearchIndex() {
|
||||||
|
return PhabricatorSearchField::FIELD_BODY;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,8 +103,22 @@ final class DifferentialTestPlanFieldSpecification
|
|||||||
return "TEST PLAN\n".preg_replace('/^/m', ' ', $this->plan);
|
return "TEST PLAN\n".preg_replace('/^/m', ' ', $this->plan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shouldAddToSearchIndex() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValueForSearchIndex() {
|
||||||
|
return $this->plan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getKeyForSearchIndex() {
|
||||||
|
return 'tpln';
|
||||||
|
}
|
||||||
|
|
||||||
private function isRequired() {
|
private function isRequired() {
|
||||||
return PhabricatorEnv::getEnvConfig('differential.require-test-plan-field');
|
return PhabricatorEnv::getEnvConfig('differential.require-test-plan-field');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ final class PhabricatorSearchField {
|
|||||||
|
|
||||||
const FIELD_TITLE = 'titl';
|
const FIELD_TITLE = 'titl';
|
||||||
const FIELD_BODY = 'body';
|
const FIELD_BODY = 'body';
|
||||||
const FIELD_TEST_PLAN = 'tpln';
|
|
||||||
const FIELD_COMMENT = 'cmnt';
|
const FIELD_COMMENT = 'cmnt';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,23 @@ final class PhabricatorSearchDifferentialIndexer
|
|||||||
$doc->setDocumentCreated($rev->getDateCreated());
|
$doc->setDocumentCreated($rev->getDateCreated());
|
||||||
$doc->setDocumentModified($rev->getDateModified());
|
$doc->setDocumentModified($rev->getDateModified());
|
||||||
|
|
||||||
$doc->addField(
|
$aux_fields = DifferentialFieldSelector::newSelector()
|
||||||
PhabricatorSearchField::FIELD_BODY,
|
->getFieldSpecifications();
|
||||||
$rev->getSummary());
|
foreach ($aux_fields as $key => $aux_field) {
|
||||||
$doc->addField(
|
if (!$aux_field->shouldAddToSearchIndex()) {
|
||||||
PhabricatorSearchField::FIELD_TEST_PLAN,
|
unset($aux_fields[$key]);
|
||||||
$rev->getTestPlan());
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$aux_fields = DifferentialAuxiliaryField::loadFromStorage(
|
||||||
|
$rev,
|
||||||
|
$aux_fields);
|
||||||
|
foreach ($aux_fields as $aux_field) {
|
||||||
|
$doc->addField(
|
||||||
|
$aux_field->getKeyForSearchIndex(),
|
||||||
|
$aux_field->getValueForSearchIndex()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$doc->addRelationship(
|
$doc->addRelationship(
|
||||||
PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
|
PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
|
||||||
|
|||||||
Reference in New Issue
Block a user