mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +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 $beforeTransactionID;
|
||||
private $transactionLimit;
|
||||
private $fulltext;
|
||||
|
||||
public function needFilePHIDs($need_file_phids) {
|
||||
$this->needFilePHIDs = $need_file_phids;
|
||||
|
@ -82,6 +83,11 @@ final class ConpherenceThreadQuery
|
|||
return $this->transactionLimit;
|
||||
}
|
||||
|
||||
public function withFulltext($query) {
|
||||
$this->fulltext = $query;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function loadPage() {
|
||||
$table = new ConpherenceThread();
|
||||
$conn_r = $table->establishConnection('r');
|
||||
|
@ -122,7 +128,7 @@ final class ConpherenceThreadQuery
|
|||
}
|
||||
|
||||
protected function buildGroupClause(AphrontDatabaseConnection $conn_r) {
|
||||
if ($this->participantPHIDs !== null) {
|
||||
if ($this->participantPHIDs !== null || strlen($this->fulltext)) {
|
||||
return 'GROUP BY conpherence_thread.id';
|
||||
} else {
|
||||
return $this->buildApplicationSearchGroupClause($conn_r);
|
||||
|
@ -149,6 +155,12 @@ final class ConpherenceThreadQuery
|
|||
$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);
|
||||
return implode(' ', $joins);
|
||||
|
@ -196,6 +208,13 @@ final class ConpherenceThreadQuery
|
|||
(int)$this->isRoom);
|
||||
}
|
||||
|
||||
if (strlen($this->fulltext)) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'MATCH(idx.corpus) AGAINST (%s IN BOOLEAN MODE)',
|
||||
$this->fulltext);
|
||||
}
|
||||
|
||||
$viewer = $this->getViewer();
|
||||
if ($this->shouldJoinForViewer($viewer)) {
|
||||
$where[] = qsprintf(
|
||||
|
|
|
@ -18,6 +18,8 @@ final class ConpherenceThreadSearchEngine
|
|||
'participantPHIDs',
|
||||
$this->readUsersFromRequest($request, 'participants'));
|
||||
|
||||
$saved->setParameter('fulltext', $request->getStr('fulltext'));
|
||||
|
||||
$saved->setParameter(
|
||||
'threadType',
|
||||
$request->getStr('threadType'));
|
||||
|
@ -34,6 +36,11 @@ final class ConpherenceThreadSearchEngine
|
|||
$query->withParticipantPHIDs($participant_phids);
|
||||
}
|
||||
|
||||
$fulltext = $saved->getParameter('fulltext');
|
||||
if (strlen($fulltext)) {
|
||||
$query->withFulltext($fulltext);
|
||||
}
|
||||
|
||||
$thread_type = $saved->getParameter('threadType');
|
||||
if (idx($this->getTypeOptions(), $thread_type)) {
|
||||
switch ($thread_type) {
|
||||
|
@ -57,6 +64,7 @@ final class ConpherenceThreadSearchEngine
|
|||
PhabricatorSavedQuery $saved) {
|
||||
|
||||
$participant_phids = $saved->getParameter('participantPHIDs', array());
|
||||
$fulltext = $saved->getParameter('fulltext');
|
||||
|
||||
$form
|
||||
->appendControl(
|
||||
|
@ -65,6 +73,11 @@ final class ConpherenceThreadSearchEngine
|
|||
->setName('participants')
|
||||
->setLabel(pht('Participants'))
|
||||
->setValue($participant_phids))
|
||||
->appendControl(
|
||||
id(new AphrontFormTextControl())
|
||||
->setName('fulltext')
|
||||
->setLabel(pht('Contains Words'))
|
||||
->setValue($fulltext))
|
||||
->appendControl(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel(pht('Type'))
|
||||
|
|
Loading…
Reference in a new issue