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

View file

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

View file

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