mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Integrate Diviner with global search
Summary: Fixes T7458. Integrates #diviner into #applicationsearch by indexing `DivinerLiveBook` and `DivinerLiveSymbol` search documents. Depends on D13157. Test Plan: Ran `./bin/search index --all --type BOOK` and `./bin/search index --all --type ATOM` and then searched for various symbols via global search. Reviewers: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Maniphest Tasks: T7458 Differential Revision: https://secure.phabricator.com/D13090
This commit is contained in:
parent
0d50c40973
commit
b9d004e9c4
9 changed files with 93 additions and 9 deletions
|
@ -642,12 +642,14 @@ phutil_register_library_map(array(
|
|||
'DivinerAtomQuery' => 'applications/diviner/query/DivinerAtomQuery.php',
|
||||
'DivinerAtomRef' => 'applications/diviner/atom/DivinerAtomRef.php',
|
||||
'DivinerAtomSearchEngine' => 'applications/diviner/query/DivinerAtomSearchEngine.php',
|
||||
'DivinerAtomSearchIndexer' => 'applications/diviner/search/DivinerAtomSearchIndexer.php',
|
||||
'DivinerAtomizeWorkflow' => 'applications/diviner/workflow/DivinerAtomizeWorkflow.php',
|
||||
'DivinerAtomizer' => 'applications/diviner/atomizer/DivinerAtomizer.php',
|
||||
'DivinerBookController' => 'applications/diviner/controller/DivinerBookController.php',
|
||||
'DivinerBookItemView' => 'applications/diviner/view/DivinerBookItemView.php',
|
||||
'DivinerBookPHIDType' => 'applications/diviner/phid/DivinerBookPHIDType.php',
|
||||
'DivinerBookQuery' => 'applications/diviner/query/DivinerBookQuery.php',
|
||||
'DivinerBookSearchIndexer' => 'applications/diviner/search/DivinerBookSearchIndexer.php',
|
||||
'DivinerController' => 'applications/diviner/controller/DivinerController.php',
|
||||
'DivinerDAO' => 'applications/diviner/storage/DivinerDAO.php',
|
||||
'DivinerDefaultRenderer' => 'applications/diviner/renderer/DivinerDefaultRenderer.php',
|
||||
|
@ -3884,11 +3886,13 @@ phutil_register_library_map(array(
|
|||
'DivinerAtomPHIDType' => 'PhabricatorPHIDType',
|
||||
'DivinerAtomQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'DivinerAtomSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'DivinerAtomSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
|
||||
'DivinerAtomizeWorkflow' => 'DivinerWorkflow',
|
||||
'DivinerBookController' => 'DivinerController',
|
||||
'DivinerBookItemView' => 'AphrontTagView',
|
||||
'DivinerBookPHIDType' => 'PhabricatorPHIDType',
|
||||
'DivinerBookQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'DivinerBookSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
|
||||
'DivinerController' => 'PhabricatorController',
|
||||
'DivinerDAO' => 'PhabricatorLiskDAO',
|
||||
'DivinerDefaultRenderer' => 'DivinerRenderer',
|
||||
|
@ -3899,6 +3903,7 @@ phutil_register_library_map(array(
|
|||
'DivinerLiveBook' => array(
|
||||
'DivinerDAO',
|
||||
'PhabricatorPolicyInterface',
|
||||
'PhabricatorProjectInterface',
|
||||
'PhabricatorDestructibleInterface',
|
||||
),
|
||||
'DivinerLivePublisher' => 'DivinerPublisher',
|
||||
|
|
|
@ -58,4 +58,11 @@ final class PhabricatorDivinerApplication extends PhabricatorApplication {
|
|||
);
|
||||
}
|
||||
|
||||
public function getApplicationSearchDocumentTypes() {
|
||||
return array(
|
||||
DivinerAtomPHIDType::TYPECONST,
|
||||
DivinerBookPHIDType::TYPECONST,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ final class DivinerAtomPHIDType extends PhabricatorPHIDType {
|
|||
const TYPECONST = 'ATOM';
|
||||
|
||||
public function getTypeName() {
|
||||
return pht('Atom');
|
||||
return pht('Diviner Atom');
|
||||
}
|
||||
|
||||
public function newObject() {
|
||||
|
@ -28,8 +28,17 @@ final class DivinerAtomPHIDType extends PhabricatorPHIDType {
|
|||
foreach ($handles as $phid => $handle) {
|
||||
$atom = $objects[$phid];
|
||||
|
||||
$handle->setName($atom->getTitle());
|
||||
$handle->setURI($atom->getName());
|
||||
$book = $atom->getBook()->getName();
|
||||
$name = $atom->getName();
|
||||
$type = $atom->getType();
|
||||
|
||||
$handle
|
||||
->setName($atom->getName())
|
||||
->setTitle($atom->getTitle())
|
||||
->setURI("/book/{$book}/{$type}/{$name}/")
|
||||
->setStatus($atom->getGraphHash()
|
||||
? PhabricatorObjectHandle::STATUS_OPEN
|
||||
: PhabricatorObjectHandle::STATUS_CLOSED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ final class DivinerBookPHIDType extends PhabricatorPHIDType {
|
|||
const TYPECONST = 'BOOK';
|
||||
|
||||
public function getTypeName() {
|
||||
return pht('Book');
|
||||
return pht('Diviner Book');
|
||||
}
|
||||
|
||||
public function newObject() {
|
||||
|
@ -30,9 +30,10 @@ final class DivinerBookPHIDType extends PhabricatorPHIDType {
|
|||
|
||||
$name = $book->getName();
|
||||
|
||||
$handle->setName($book->getShortTitle());
|
||||
$handle->setFullName($book->getTitle());
|
||||
$handle->setURI("/diviner/book/{$name}/");
|
||||
$handle
|
||||
->setName($book->getShortTitle())
|
||||
->setFullName($book->getTitle())
|
||||
->setURI("/book/{$name}/");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,9 @@ final class DivinerLivePublisher extends DivinerPublisher {
|
|||
|
||||
$book->setConfigurationData($this->getConfigurationData())->save();
|
||||
$this->book = $book;
|
||||
|
||||
id(new PhabricatorSearchIndexer())
|
||||
->queueDocumentForIndexing($book->getPHID());
|
||||
}
|
||||
|
||||
return $this->book;
|
||||
|
@ -122,6 +125,9 @@ final class DivinerLivePublisher extends DivinerPublisher {
|
|||
|
||||
$symbol->save();
|
||||
|
||||
id(new PhabricatorSearchIndexer())
|
||||
->queueDocumentForIndexing($symbol->getPHID());
|
||||
|
||||
// TODO: We probably need a finer-grained sense of what "documentable"
|
||||
// atoms are. Neither files nor methods are currently considered
|
||||
// documentable, but for different reasons: files appear nowhere, while
|
||||
|
|
31
src/applications/diviner/search/DivinerAtomSearchIndexer.php
Normal file
31
src/applications/diviner/search/DivinerAtomSearchIndexer.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
final class DivinerAtomSearchIndexer extends PhabricatorSearchDocumentIndexer {
|
||||
|
||||
public function getIndexableObject() {
|
||||
return new DivinerLiveSymbol();
|
||||
}
|
||||
|
||||
protected function buildAbstractDocumentByPHID($phid) {
|
||||
$atom = $this->loadDocumentByPHID($phid);
|
||||
$book = $atom->getBook();
|
||||
|
||||
$doc = $this->newDocument($phid)
|
||||
->setDocumentTitle($atom->getTitle())
|
||||
->setDocumentCreated($book->getDateCreated())
|
||||
->setDocumentModified($book->getDateModified());
|
||||
|
||||
$doc->addField(
|
||||
PhabricatorSearchField::FIELD_BODY,
|
||||
$atom->getSummary());
|
||||
|
||||
$doc->addRelationship(
|
||||
PhabricatorSearchRelationship::RELATIONSHIP_BOOK,
|
||||
$atom->getBookPHID(),
|
||||
DivinerBookPHIDType::TYPECONST,
|
||||
$book->getDateCreated());
|
||||
|
||||
return $doc;
|
||||
}
|
||||
|
||||
}
|
25
src/applications/diviner/search/DivinerBookSearchIndexer.php
Normal file
25
src/applications/diviner/search/DivinerBookSearchIndexer.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
final class DivinerBookSearchIndexer extends PhabricatorSearchDocumentIndexer {
|
||||
|
||||
public function getIndexableObject() {
|
||||
return new DivinerLiveBook();
|
||||
}
|
||||
|
||||
protected function buildAbstractDocumentByPHID($phid) {
|
||||
$book = $this->loadDocumentByPHID($phid);
|
||||
|
||||
$doc = $this->newDocument($phid)
|
||||
->setDocumentTitle($book->getTitle())
|
||||
->setDocumentCreated($book->getDateCreated())
|
||||
->setDocumentModified($book->getDateModified());
|
||||
|
||||
$doc->addField(
|
||||
PhabricatorSearchField::FIELD_BODY,
|
||||
$book->getPreface());
|
||||
|
||||
return $doc;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -42,8 +42,7 @@ final class DivinerLiveBook extends DivinerDAO
|
|||
}
|
||||
|
||||
public function generatePHID() {
|
||||
return PhabricatorPHID::generateNewPHID(
|
||||
DivinerBookPHIDType::TYPECONST);
|
||||
return PhabricatorPHID::generateNewPHID(DivinerBookPHIDType::TYPECONST);
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
final class PhabricatorSearchRelationship {
|
||||
|
||||
const RELATIONSHIP_AUTHOR = 'auth';
|
||||
const RELATIONSHIP_BOOK = 'book';
|
||||
const RELATIONSHIP_REVIEWER = 'revw';
|
||||
const RELATIONSHIP_SUBSCRIBER = 'subs';
|
||||
const RELATIONSHIP_COMMENTER = 'comm';
|
||||
|
|
Loading…
Reference in a new issue