@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Support searching for Harbormater build plans by name substring

Summary: Ref T10457. Allow build plans to be queried by name.

Test Plan:
- Searched for plans by name.
- Renamed a plan, searched for new name.

{F1133085}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10457

Differential Revision: https://secure.phabricator.com/D15359

+79 -6
+7
resources/sql/autopatches/20160227.harbormaster.1.plann.sql
··· 1 + CREATE TABLE {$NAMESPACE}_harbormaster.harbormaster_buildplanname_ngrams ( 2 + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 3 + objectID INT UNSIGNED NOT NULL, 4 + ngram CHAR(3) NOT NULL COLLATE {$COLLATE_TEXT}, 5 + KEY `key_object` (objectID), 6 + KEY `key_ngram` (ngram, objectID) 7 + ) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
+11
resources/sql/autopatches/20160227.harbormaster.2.plani.php
··· 1 + <?php 2 + 3 + $table = new HarbormasterBuildPlan(); 4 + 5 + foreach (new LiskMigrationIterator($table) as $plan) { 6 + PhabricatorSearchWorker::queueDocumentForIndexing( 7 + $plan->getPHID(), 8 + array( 9 + 'force' => true, 10 + )); 11 + }
+3
src/__phutil_library_map__.php
··· 1055 1055 'HarbormasterBuildPlanDefaultViewCapability' => 'applications/harbormaster/capability/HarbormasterBuildPlanDefaultViewCapability.php', 1056 1056 'HarbormasterBuildPlanEditEngine' => 'applications/harbormaster/editor/HarbormasterBuildPlanEditEngine.php', 1057 1057 'HarbormasterBuildPlanEditor' => 'applications/harbormaster/editor/HarbormasterBuildPlanEditor.php', 1058 + 'HarbormasterBuildPlanNameNgrams' => 'applications/harbormaster/storage/configuration/HarbormasterBuildPlanNameNgrams.php', 1058 1059 'HarbormasterBuildPlanPHIDType' => 'applications/harbormaster/phid/HarbormasterBuildPlanPHIDType.php', 1059 1060 'HarbormasterBuildPlanQuery' => 'applications/harbormaster/query/HarbormasterBuildPlanQuery.php', 1060 1061 'HarbormasterBuildPlanSearchEngine' => 'applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php', ··· 5199 5200 'PhabricatorApplicationTransactionInterface', 5200 5201 'PhabricatorPolicyInterface', 5201 5202 'PhabricatorSubscribableInterface', 5203 + 'PhabricatorNgramsInterface', 5202 5204 ), 5203 5205 'HarbormasterBuildPlanDatasource' => 'PhabricatorTypeaheadDatasource', 5204 5206 'HarbormasterBuildPlanDefaultEditCapability' => 'PhabricatorPolicyCapability', 5205 5207 'HarbormasterBuildPlanDefaultViewCapability' => 'PhabricatorPolicyCapability', 5206 5208 'HarbormasterBuildPlanEditEngine' => 'PhabricatorEditEngine', 5207 5209 'HarbormasterBuildPlanEditor' => 'PhabricatorApplicationTransactionEditor', 5210 + 'HarbormasterBuildPlanNameNgrams' => 'PhabricatorSearchNgrams', 5208 5211 'HarbormasterBuildPlanPHIDType' => 'PhabricatorPHIDType', 5209 5212 'HarbormasterBuildPlanQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 5210 5213 'HarbormasterBuildPlanSearchEngine' => 'PhabricatorApplicationSearchEngine',
+4
src/applications/harbormaster/editor/HarbormasterBuildPlanEditor.php
··· 11 11 return pht('Harbormaster Build Plans'); 12 12 } 13 13 14 + protected function supportsSearch() { 15 + return true; 16 + } 17 + 14 18 public function getTransactionTypes() { 15 19 $types = parent::getTransactionTypes(); 16 20 $types[] = HarbormasterBuildPlanTransaction::TYPE_NAME;
+15 -5
src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php
··· 35 35 return $this; 36 36 } 37 37 38 + public function withNameNgrams($ngrams) { 39 + return $this->withNgramsConstraint( 40 + new HarbormasterBuildPlanNameNgrams(), 41 + $ngrams); 42 + } 43 + 38 44 public function needBuildSteps($need) { 39 45 $this->needBuildSteps = $need; 40 46 return $this; ··· 74 80 if ($this->ids !== null) { 75 81 $where[] = qsprintf( 76 82 $conn, 77 - 'id IN (%Ld)', 83 + 'plan.id IN (%Ld)', 78 84 $this->ids); 79 85 } 80 86 81 87 if ($this->phids !== null) { 82 88 $where[] = qsprintf( 83 89 $conn, 84 - 'phid IN (%Ls)', 90 + 'plan.phid IN (%Ls)', 85 91 $this->phids); 86 92 } 87 93 88 94 if ($this->statuses !== null) { 89 95 $where[] = qsprintf( 90 96 $conn, 91 - 'planStatus IN (%Ls)', 97 + 'plan.planStatus IN (%Ls)', 92 98 $this->statuses); 93 99 } 94 100 95 101 if (strlen($this->datasourceQuery)) { 96 102 $where[] = qsprintf( 97 103 $conn, 98 - 'name LIKE %>', 104 + 'plan.name LIKE %>', 99 105 $this->datasourceQuery); 100 106 } 101 107 102 108 if ($this->planAutoKeys !== null) { 103 109 $where[] = qsprintf( 104 110 $conn, 105 - 'planAutoKey IN (%Ls)', 111 + 'plan.planAutoKey IN (%Ls)', 106 112 $this->planAutoKeys); 107 113 } 108 114 109 115 return $where; 116 + } 117 + 118 + protected function getPrimaryTableAlias() { 119 + return 'plan'; 110 120 } 111 121 112 122 public function getQueryApplicationClass() {
+8
src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php
··· 17 17 18 18 protected function buildCustomSearchFields() { 19 19 return array( 20 + id(new PhabricatorSearchTextField()) 21 + ->setLabel(pht('Name Contains')) 22 + ->setKey('match') 23 + ->setDescription(pht('Search for namespaces by name substring.')), 20 24 id(new PhabricatorSearchCheckboxesField()) 21 25 ->setLabel(pht('Status')) 22 26 ->setKey('status') ··· 31 35 32 36 protected function buildQueryFromParameters(array $map) { 33 37 $query = $this->newQuery(); 38 + 39 + if ($map['match'] !== null) { 40 + $query->withNameNgrams($map['match']); 41 + } 34 42 35 43 if ($map['status']) { 36 44 $query->withStatuses($map['status']);
+13 -1
src/applications/harbormaster/storage/configuration/HarbormasterBuildPlan.php
··· 7 7 implements 8 8 PhabricatorApplicationTransactionInterface, 9 9 PhabricatorPolicyInterface, 10 - PhabricatorSubscribableInterface { 10 + PhabricatorSubscribableInterface, 11 + PhabricatorNgramsInterface { 11 12 12 13 protected $name; 13 14 protected $planStatus; ··· 196 197 } 197 198 198 199 return $messages; 200 + } 201 + 202 + 203 + /* -( PhabricatorNgramInterface )------------------------------------------ */ 204 + 205 + 206 + public function newNgrams() { 207 + return array( 208 + id(new HarbormasterBuildPlanNameNgrams()) 209 + ->setValue($this->getName()), 210 + ); 199 211 } 200 212 201 213 }
+18
src/applications/harbormaster/storage/configuration/HarbormasterBuildPlanNameNgrams.php
··· 1 + <?php 2 + 3 + final class HarbormasterBuildPlanNameNgrams 4 + extends PhabricatorSearchNgrams { 5 + 6 + public function getNgramKey() { 7 + return 'buildplanname'; 8 + } 9 + 10 + public function getColumnName() { 11 + return 'name'; 12 + } 13 + 14 + public function getApplicationName() { 15 + return 'harbormaster'; 16 + } 17 + 18 + }