Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14763637
D12428.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12428.diff
View Options
diff --git a/src/applications/project/query/PhabricatorProjectQuery.php b/src/applications/project/query/PhabricatorProjectQuery.php
--- a/src/applications/project/query/PhabricatorProjectQuery.php
+++ b/src/applications/project/query/PhabricatorProjectQuery.php
@@ -9,7 +9,7 @@
private $slugs;
private $phrictionSlugs;
private $names;
- private $datasourceQuery;
+ private $nameTokens;
private $icons;
private $colors;
@@ -60,8 +60,8 @@
return $this;
}
- public function withDatasourceQuery($string) {
- $this->datasourceQuery = $string;
+ public function withNameTokens(array $tokens) {
+ $this->nameTokens = array_values($tokens);
return $this;
}
@@ -329,7 +329,7 @@
}
private function buildGroupClause($conn_r) {
- if ($this->memberPHIDs || $this->datasourceQuery) {
+ if ($this->memberPHIDs || $this->nameTokens) {
return 'GROUP BY p.id';
} else {
return $this->buildApplicationSearchGroupClause($conn_r);
@@ -363,23 +363,18 @@
id(new PhabricatorProjectSlug())->getTableName());
}
- if ($this->datasourceQuery !== null) {
- $tokens = PhabricatorTypeaheadDatasource::tokenizeString(
- $this->datasourceQuery);
- if (!$tokens) {
- throw new PhabricatorEmptyQueryException();
+ if ($this->nameTokens !== null) {
+ foreach ($this->nameTokens as $key => $token) {
+ $token_table = 'token_'.$key;
+ $joins[] = qsprintf(
+ $conn_r,
+ 'JOIN %T %T ON %T.projectID = p.id AND %T.token LIKE %>',
+ PhabricatorProject::TABLE_DATASOURCE_TOKEN,
+ $token_table,
+ $token_table,
+ $token_table,
+ $token);
}
-
- $likes = array();
- foreach ($tokens as $token) {
- $likes[] = qsprintf($conn_r, 'token.token LIKE %>', $token);
- }
-
- $joins[] = qsprintf(
- $conn_r,
- 'JOIN %T token ON token.projectID = p.id AND (%Q)',
- PhabricatorProject::TABLE_DATASOURCE_TOKEN,
- '('.implode(') OR (', $likes).')');
}
$joins[] = $this->buildApplicationSearchJoinClause($conn_r);
diff --git a/src/applications/project/query/PhabricatorProjectSearchEngine.php b/src/applications/project/query/PhabricatorProjectSearchEngine.php
--- a/src/applications/project/query/PhabricatorProjectSearchEngine.php
+++ b/src/applications/project/query/PhabricatorProjectSearchEngine.php
@@ -55,7 +55,8 @@
$name = $saved->getParameter('name');
if (strlen($name)) {
- $query->withDatasourceQuery($name);
+ $tokens = PhabricatorTypeaheadDatasource::tokenizeString($name);
+ $query->withNameTokens($tokens);
}
$icons = $saved->getParameter('icons');
diff --git a/src/applications/project/typeahead/PhabricatorProjectDatasource.php b/src/applications/project/typeahead/PhabricatorProjectDatasource.php
--- a/src/applications/project/typeahead/PhabricatorProjectDatasource.php
+++ b/src/applications/project/typeahead/PhabricatorProjectDatasource.php
@@ -18,17 +18,18 @@
// Allow users to type "#qa" or "qa" to find "Quality Assurance".
$raw_query = ltrim($raw_query, '#');
+ $tokens = self::tokenizeString($raw_query);
- if (!strlen($raw_query)) {
- return array();
+ $query = id(new PhabricatorProjectQuery())
+ ->needImages(true)
+ ->needSlugs(true);
+
+ if ($tokens) {
+ $query->withNameTokens($tokens);
}
- $projs = id(new PhabricatorProjectQuery())
- ->setViewer($viewer)
- ->needImages(true)
- ->needSlugs(true)
- ->withDatasourceQuery($raw_query)
- ->execute();
+ $projs = $this->executeQuery($query);
+
$projs = mpull($projs, null, 'getPHID');
$must_have_cols = $this->getParameter('mustHaveColumns', false);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 24, 12:13 PM (19 h, 12 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7040274
Default Alt Text
D12428.diff (3 KB)
Attached To
Mode
D12428: Improve browsability of Projects query
Attached
Detach File
Event Timeline
Log In to Comment