1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 12:52:42 +01:00

Support tokenizer functions in Diffusion

Summary: Ref T4100. Ref T5595. Support tokenizer functions + edgelogic for repositories.

Test Plan: Searched for repositories.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5595, T4100

Differential Revision: https://secure.phabricator.com/D12533
This commit is contained in:
epriestley 2015-04-23 08:25:17 -07:00
parent 83617073f5
commit cf154ae9f4
3 changed files with 67 additions and 50 deletions

View file

@ -8,7 +8,7 @@
return array( return array(
'names' => array( 'names' => array(
'core.pkg.css' => '9a9b59ca', 'core.pkg.css' => '9a9b59ca',
'core.pkg.js' => '80671b76', 'core.pkg.js' => '348d5193',
'darkconsole.pkg.js' => '8ab24e01', 'darkconsole.pkg.js' => '8ab24e01',
'differential.pkg.css' => '3500921f', 'differential.pkg.css' => '3500921f',
'differential.pkg.js' => 'c0506961', 'differential.pkg.js' => 'c0506961',
@ -222,7 +222,7 @@ return array(
'rsrc/externals/javelin/lib/__tests__/URI.js' => '1e45fda9', 'rsrc/externals/javelin/lib/__tests__/URI.js' => '1e45fda9',
'rsrc/externals/javelin/lib/__tests__/behavior.js' => '1ea62783', 'rsrc/externals/javelin/lib/__tests__/behavior.js' => '1ea62783',
'rsrc/externals/javelin/lib/behavior.js' => '61cbc29a', 'rsrc/externals/javelin/lib/behavior.js' => '61cbc29a',
'rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js' => '3ff74d77', 'rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js' => 'ab5f468d',
'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => '70baed2f', 'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => '70baed2f',
'rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js' => 'e6e25838', 'rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js' => 'e6e25838',
'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js' => '503e17fd', 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js' => '503e17fd',
@ -689,7 +689,7 @@ return array(
'javelin-scrollbar' => 'eaa5b321', 'javelin-scrollbar' => 'eaa5b321',
'javelin-sound' => '949c0fe5', 'javelin-sound' => '949c0fe5',
'javelin-stratcom' => '6c53634d', 'javelin-stratcom' => '6c53634d',
'javelin-tokenizer' => '3ff74d77', 'javelin-tokenizer' => 'ab5f468d',
'javelin-typeahead' => '70baed2f', 'javelin-typeahead' => '70baed2f',
'javelin-typeahead-composite-source' => '503e17fd', 'javelin-typeahead-composite-source' => '503e17fd',
'javelin-typeahead-normalizer' => 'e6e25838', 'javelin-typeahead-normalizer' => 'e6e25838',
@ -1080,12 +1080,6 @@ return array(
'javelin-dom', 'javelin-dom',
'phortune-credit-card-form', 'phortune-credit-card-form',
), ),
'3ff74d77' => array(
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-install',
),
'40a6a403' => array( '40a6a403' => array(
'javelin-install', 'javelin-install',
'javelin-dom', 'javelin-dom',
@ -1669,6 +1663,12 @@ return array(
'javelin-util', 'javelin-util',
'phabricator-prefab', 'phabricator-prefab',
), ),
'ab5f468d' => array(
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-install',
),
'b1a59974' => array( 'b1a59974' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-aphlict', 'javelin-aphlict',

View file

@ -10,7 +10,6 @@ final class PhabricatorRepositoryQuery
private $uuids; private $uuids;
private $nameContains; private $nameContains;
private $remoteURIs; private $remoteURIs;
private $anyProjectPHIDs;
private $datasourceQuery; private $datasourceQuery;
private $numericIdentifiers; private $numericIdentifiers;
@ -99,11 +98,6 @@ final class PhabricatorRepositoryQuery
return $this; return $this;
} }
public function withAnyProjects(array $projects) {
$this->anyProjectPHIDs = $projects;
return $this;
}
public function withDatasourceQuery($query) { public function withDatasourceQuery($query) {
$this->datasourceQuery = $query; $this->datasourceQuery = $query;
return $this; return $this;
@ -163,10 +157,13 @@ final class PhabricatorRepositoryQuery
$data = queryfx_all( $data = queryfx_all(
$conn_r, $conn_r,
'SELECT * FROM %T r %Q %Q %Q %Q', '%Q FROM %T r %Q %Q %Q %Q %Q %Q',
$this->buildSelectClause($conn_r),
$table->getTableName(), $table->getTableName(),
$this->buildJoinsClause($conn_r), $this->buildJoinClause($conn_r),
$this->buildWhereClause($conn_r), $this->buildWhereClause($conn_r),
$this->buildGroupClause($conn_r),
$this->buildHavingClause($conn_r),
$this->buildOrderClause($conn_r), $this->buildOrderClause($conn_r),
$this->buildLimitClause($conn_r)); $this->buildLimitClause($conn_r));
@ -390,32 +387,46 @@ final class PhabricatorRepositoryQuery
return $map; return $map;
} }
private function buildJoinsClause(AphrontDatabaseConnection $conn_r) { protected function buildSelectClause(AphrontDatabaseConnection $conn) {
$joins = array(); $parts = $this->buildSelectClauseParts($conn);
if ($this->shouldJoinSummaryTable()) {
$join_summary_table = $this->needCommitCounts || $parts[] = 's.*';
$this->needMostRecentCommits;
$vector = $this->getOrderVector();
if ($vector->containsKey('committed') ||
$vector->containsKey('size')) {
$join_summary_table = true;
} }
return $this->formatSelectClause($parts);
}
if ($join_summary_table) { protected function buildJoinClause(AphrontDatabaseConnection $conn_r) {
$joins = $this->buildJoinClauseParts($conn_r);
if ($this->shouldJoinSummaryTable()) {
$joins[] = qsprintf( $joins[] = qsprintf(
$conn_r, $conn_r,
'LEFT JOIN %T s ON r.id = s.repositoryID', 'LEFT JOIN %T s ON r.id = s.repositoryID',
PhabricatorRepository::TABLE_SUMMARY); PhabricatorRepository::TABLE_SUMMARY);
} }
if ($this->anyProjectPHIDs) { return $this->formatJoinClause($joins);
$joins[] = qsprintf( }
$conn_r,
'JOIN edge e ON e.src = r.phid'); private function shouldJoinSummaryTable() {
if ($this->needCommitCounts) {
return true;
} }
return implode(' ', $joins); if ($this->needMostRecentCommits) {
return true;
}
$vector = $this->getOrderVector();
if ($vector->containsKey('committed')) {
return true;
}
if ($vector->containsKey('size')) {
return true;
}
return false;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
@ -492,13 +503,6 @@ final class PhabricatorRepositoryQuery
$this->nameContains); $this->nameContains);
} }
if ($this->anyProjectPHIDs) {
$where[] = qsprintf(
$conn_r,
'e.dst IN (%Ls)',
$this->anyProjectPHIDs);
}
if (strlen($this->datasourceQuery)) { if (strlen($this->datasourceQuery)) {
// This handles having "rP" match callsigns starting with "P...". // This handles having "rP" match callsigns starting with "P...".
$query = trim($this->datasourceQuery); $query = trim($this->datasourceQuery);

View file

@ -20,7 +20,10 @@ final class PhabricatorRepositorySearchEngine
$saved->setParameter('hosted', $request->getStr('hosted')); $saved->setParameter('hosted', $request->getStr('hosted'));
$saved->setParameter('types', $request->getArr('types')); $saved->setParameter('types', $request->getArr('types'));
$saved->setParameter('name', $request->getStr('name')); $saved->setParameter('name', $request->getStr('name'));
$saved->setParameter('anyProjectPHIDs', $request->getArr('anyProjects'));
$saved->setParameter(
'projects',
$this->readProjectsFromRequest($request, 'projects'));
return $saved; return $saved;
} }
@ -60,10 +63,9 @@ final class PhabricatorRepositorySearchEngine
$query->withNameContains($name); $query->withNameContains($name);
} }
$any_project_phids = $saved->getParameter('anyProjectPHIDs'); $adjusted = clone $saved;
if ($any_project_phids) { $adjusted->setParameter('projects', $this->readProjectTokens($saved));
$query->withAnyProjects($any_project_phids); $this->setQueryProjects($query, $adjusted);
}
return $query; return $query;
} }
@ -76,7 +78,7 @@ final class PhabricatorRepositorySearchEngine
$types = $saved_query->getParameter('types', array()); $types = $saved_query->getParameter('types', array());
$types = array_fuse($types); $types = array_fuse($types);
$name = $saved_query->getParameter('name'); $name = $saved_query->getParameter('name');
$any_project_phids = $saved_query->getParameter('anyProjectPHIDs', array()); $projects = $this->readProjectTokens($saved_query);
$form $form
->appendChild( ->appendChild(
@ -91,10 +93,10 @@ final class PhabricatorRepositorySearchEngine
->setValue($name)) ->setValue($name))
->appendControl( ->appendControl(
id(new AphrontFormTokenizerControl()) id(new AphrontFormTokenizerControl())
->setDatasource(new PhabricatorProjectDatasource()) ->setDatasource(new PhabricatorProjectLogicalDatasource())
->setName('anyProjects') ->setName('projects')
->setLabel(pht('In Any Project')) ->setLabel(pht('Projects'))
->setValue($any_project_phids)) ->setValue($projects))
->appendChild( ->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormSelectControl())
->setName('status') ->setName('status')
@ -266,4 +268,15 @@ final class PhabricatorRepositorySearchEngine
return $list; return $list;
} }
private function readProjectTokens(PhabricatorSavedQuery $saved) {
$projects = $saved->getParameter('projects', array());
$any = $saved->getParameter('anyProjectPHIDs', array());
foreach ($any as $project) {
$projects[] = 'any('.$project.')';
}
return $projects;
}
} }