mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-08 10:24:48 +01:00
Provide basic fulltext search for Conpherence
Summary: Ref T3165. This needs more work but does the basics. Test Plan: {F387514} Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T3165 Differential Revision: https://secure.phabricator.com/D12588
This commit is contained in:
parent
c6fa4355cc
commit
3c80292295
2 changed files with 33 additions and 1 deletions
|
@ -17,6 +17,7 @@ final class ConpherenceThreadQuery
|
||||||
private $afterTransactionID;
|
private $afterTransactionID;
|
||||||
private $beforeTransactionID;
|
private $beforeTransactionID;
|
||||||
private $transactionLimit;
|
private $transactionLimit;
|
||||||
|
private $fulltext;
|
||||||
|
|
||||||
public function needFilePHIDs($need_file_phids) {
|
public function needFilePHIDs($need_file_phids) {
|
||||||
$this->needFilePHIDs = $need_file_phids;
|
$this->needFilePHIDs = $need_file_phids;
|
||||||
|
@ -82,6 +83,11 @@ final class ConpherenceThreadQuery
|
||||||
return $this->transactionLimit;
|
return $this->transactionLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withFulltext($query) {
|
||||||
|
$this->fulltext = $query;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
protected function loadPage() {
|
protected function loadPage() {
|
||||||
$table = new ConpherenceThread();
|
$table = new ConpherenceThread();
|
||||||
$conn_r = $table->establishConnection('r');
|
$conn_r = $table->establishConnection('r');
|
||||||
|
@ -122,7 +128,7 @@ final class ConpherenceThreadQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function buildGroupClause(AphrontDatabaseConnection $conn_r) {
|
protected function buildGroupClause(AphrontDatabaseConnection $conn_r) {
|
||||||
if ($this->participantPHIDs !== null) {
|
if ($this->participantPHIDs !== null || strlen($this->fulltext)) {
|
||||||
return 'GROUP BY conpherence_thread.id';
|
return 'GROUP BY conpherence_thread.id';
|
||||||
} else {
|
} else {
|
||||||
return $this->buildApplicationSearchGroupClause($conn_r);
|
return $this->buildApplicationSearchGroupClause($conn_r);
|
||||||
|
@ -149,6 +155,12 @@ final class ConpherenceThreadQuery
|
||||||
$viewer->getPHID());
|
$viewer->getPHID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strlen($this->fulltext)) {
|
||||||
|
$joins[] = qsprintf(
|
||||||
|
$conn_r,
|
||||||
|
'JOIN %T idx ON idx.threadPHID = conpherence_thread.phid',
|
||||||
|
id(new ConpherenceIndex())->getTableName());
|
||||||
|
}
|
||||||
|
|
||||||
$joins[] = $this->buildApplicationSearchJoinClause($conn_r);
|
$joins[] = $this->buildApplicationSearchJoinClause($conn_r);
|
||||||
return implode(' ', $joins);
|
return implode(' ', $joins);
|
||||||
|
@ -196,6 +208,13 @@ final class ConpherenceThreadQuery
|
||||||
(int)$this->isRoom);
|
(int)$this->isRoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strlen($this->fulltext)) {
|
||||||
|
$where[] = qsprintf(
|
||||||
|
$conn_r,
|
||||||
|
'MATCH(idx.corpus) AGAINST (%s IN BOOLEAN MODE)',
|
||||||
|
$this->fulltext);
|
||||||
|
}
|
||||||
|
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
if ($this->shouldJoinForViewer($viewer)) {
|
if ($this->shouldJoinForViewer($viewer)) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
|
|
|
@ -18,6 +18,8 @@ final class ConpherenceThreadSearchEngine
|
||||||
'participantPHIDs',
|
'participantPHIDs',
|
||||||
$this->readUsersFromRequest($request, 'participants'));
|
$this->readUsersFromRequest($request, 'participants'));
|
||||||
|
|
||||||
|
$saved->setParameter('fulltext', $request->getStr('fulltext'));
|
||||||
|
|
||||||
$saved->setParameter(
|
$saved->setParameter(
|
||||||
'threadType',
|
'threadType',
|
||||||
$request->getStr('threadType'));
|
$request->getStr('threadType'));
|
||||||
|
@ -34,6 +36,11 @@ final class ConpherenceThreadSearchEngine
|
||||||
$query->withParticipantPHIDs($participant_phids);
|
$query->withParticipantPHIDs($participant_phids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$fulltext = $saved->getParameter('fulltext');
|
||||||
|
if (strlen($fulltext)) {
|
||||||
|
$query->withFulltext($fulltext);
|
||||||
|
}
|
||||||
|
|
||||||
$thread_type = $saved->getParameter('threadType');
|
$thread_type = $saved->getParameter('threadType');
|
||||||
if (idx($this->getTypeOptions(), $thread_type)) {
|
if (idx($this->getTypeOptions(), $thread_type)) {
|
||||||
switch ($thread_type) {
|
switch ($thread_type) {
|
||||||
|
@ -57,6 +64,7 @@ final class ConpherenceThreadSearchEngine
|
||||||
PhabricatorSavedQuery $saved) {
|
PhabricatorSavedQuery $saved) {
|
||||||
|
|
||||||
$participant_phids = $saved->getParameter('participantPHIDs', array());
|
$participant_phids = $saved->getParameter('participantPHIDs', array());
|
||||||
|
$fulltext = $saved->getParameter('fulltext');
|
||||||
|
|
||||||
$form
|
$form
|
||||||
->appendControl(
|
->appendControl(
|
||||||
|
@ -65,6 +73,11 @@ final class ConpherenceThreadSearchEngine
|
||||||
->setName('participants')
|
->setName('participants')
|
||||||
->setLabel(pht('Participants'))
|
->setLabel(pht('Participants'))
|
||||||
->setValue($participant_phids))
|
->setValue($participant_phids))
|
||||||
|
->appendControl(
|
||||||
|
id(new AphrontFormTextControl())
|
||||||
|
->setName('fulltext')
|
||||||
|
->setLabel(pht('Contains Words'))
|
||||||
|
->setValue($fulltext))
|
||||||
->appendControl(
|
->appendControl(
|
||||||
id(new AphrontFormSelectControl())
|
id(new AphrontFormSelectControl())
|
||||||
->setLabel(pht('Type'))
|
->setLabel(pht('Type'))
|
||||||
|
|
Loading…
Add table
Reference in a new issue