mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-25 14:08:19 +01:00
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:
parent
e53ca45fd8
commit
73bc34b26d
6 changed files with 80 additions and 7 deletions
|
@ -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());
|
||||||
|
|
||||||
|
$aux_fields = DifferentialFieldSelector::newSelector()
|
||||||
|
->getFieldSpecifications();
|
||||||
|
foreach ($aux_fields as $key => $aux_field) {
|
||||||
|
if (!$aux_field->shouldAddToSearchIndex()) {
|
||||||
|
unset($aux_fields[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$aux_fields = DifferentialAuxiliaryField::loadFromStorage(
|
||||||
|
$rev,
|
||||||
|
$aux_fields);
|
||||||
|
foreach ($aux_fields as $aux_field) {
|
||||||
$doc->addField(
|
$doc->addField(
|
||||||
PhabricatorSearchField::FIELD_BODY,
|
$aux_field->getKeyForSearchIndex(),
|
||||||
$rev->getSummary());
|
$aux_field->getValueForSearchIndex()
|
||||||
$doc->addField(
|
);
|
||||||
PhabricatorSearchField::FIELD_TEST_PLAN,
|
}
|
||||||
$rev->getTestPlan());
|
|
||||||
|
|
||||||
$doc->addRelationship(
|
$doc->addRelationship(
|
||||||
PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
|
PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
|
||||||
|
|
Loading…
Add table
Reference in a new issue