mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-25 22:18:19 +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',
|
'DivinerAtomQuery' => 'applications/diviner/query/DivinerAtomQuery.php',
|
||||||
'DivinerAtomRef' => 'applications/diviner/atom/DivinerAtomRef.php',
|
'DivinerAtomRef' => 'applications/diviner/atom/DivinerAtomRef.php',
|
||||||
'DivinerAtomSearchEngine' => 'applications/diviner/query/DivinerAtomSearchEngine.php',
|
'DivinerAtomSearchEngine' => 'applications/diviner/query/DivinerAtomSearchEngine.php',
|
||||||
|
'DivinerAtomSearchIndexer' => 'applications/diviner/search/DivinerAtomSearchIndexer.php',
|
||||||
'DivinerAtomizeWorkflow' => 'applications/diviner/workflow/DivinerAtomizeWorkflow.php',
|
'DivinerAtomizeWorkflow' => 'applications/diviner/workflow/DivinerAtomizeWorkflow.php',
|
||||||
'DivinerAtomizer' => 'applications/diviner/atomizer/DivinerAtomizer.php',
|
'DivinerAtomizer' => 'applications/diviner/atomizer/DivinerAtomizer.php',
|
||||||
'DivinerBookController' => 'applications/diviner/controller/DivinerBookController.php',
|
'DivinerBookController' => 'applications/diviner/controller/DivinerBookController.php',
|
||||||
'DivinerBookItemView' => 'applications/diviner/view/DivinerBookItemView.php',
|
'DivinerBookItemView' => 'applications/diviner/view/DivinerBookItemView.php',
|
||||||
'DivinerBookPHIDType' => 'applications/diviner/phid/DivinerBookPHIDType.php',
|
'DivinerBookPHIDType' => 'applications/diviner/phid/DivinerBookPHIDType.php',
|
||||||
'DivinerBookQuery' => 'applications/diviner/query/DivinerBookQuery.php',
|
'DivinerBookQuery' => 'applications/diviner/query/DivinerBookQuery.php',
|
||||||
|
'DivinerBookSearchIndexer' => 'applications/diviner/search/DivinerBookSearchIndexer.php',
|
||||||
'DivinerController' => 'applications/diviner/controller/DivinerController.php',
|
'DivinerController' => 'applications/diviner/controller/DivinerController.php',
|
||||||
'DivinerDAO' => 'applications/diviner/storage/DivinerDAO.php',
|
'DivinerDAO' => 'applications/diviner/storage/DivinerDAO.php',
|
||||||
'DivinerDefaultRenderer' => 'applications/diviner/renderer/DivinerDefaultRenderer.php',
|
'DivinerDefaultRenderer' => 'applications/diviner/renderer/DivinerDefaultRenderer.php',
|
||||||
|
@ -3884,11 +3886,13 @@ phutil_register_library_map(array(
|
||||||
'DivinerAtomPHIDType' => 'PhabricatorPHIDType',
|
'DivinerAtomPHIDType' => 'PhabricatorPHIDType',
|
||||||
'DivinerAtomQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'DivinerAtomQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'DivinerAtomSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'DivinerAtomSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
|
'DivinerAtomSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
|
||||||
'DivinerAtomizeWorkflow' => 'DivinerWorkflow',
|
'DivinerAtomizeWorkflow' => 'DivinerWorkflow',
|
||||||
'DivinerBookController' => 'DivinerController',
|
'DivinerBookController' => 'DivinerController',
|
||||||
'DivinerBookItemView' => 'AphrontTagView',
|
'DivinerBookItemView' => 'AphrontTagView',
|
||||||
'DivinerBookPHIDType' => 'PhabricatorPHIDType',
|
'DivinerBookPHIDType' => 'PhabricatorPHIDType',
|
||||||
'DivinerBookQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'DivinerBookQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
|
'DivinerBookSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
|
||||||
'DivinerController' => 'PhabricatorController',
|
'DivinerController' => 'PhabricatorController',
|
||||||
'DivinerDAO' => 'PhabricatorLiskDAO',
|
'DivinerDAO' => 'PhabricatorLiskDAO',
|
||||||
'DivinerDefaultRenderer' => 'DivinerRenderer',
|
'DivinerDefaultRenderer' => 'DivinerRenderer',
|
||||||
|
@ -3899,6 +3903,7 @@ phutil_register_library_map(array(
|
||||||
'DivinerLiveBook' => array(
|
'DivinerLiveBook' => array(
|
||||||
'DivinerDAO',
|
'DivinerDAO',
|
||||||
'PhabricatorPolicyInterface',
|
'PhabricatorPolicyInterface',
|
||||||
|
'PhabricatorProjectInterface',
|
||||||
'PhabricatorDestructibleInterface',
|
'PhabricatorDestructibleInterface',
|
||||||
),
|
),
|
||||||
'DivinerLivePublisher' => 'DivinerPublisher',
|
'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';
|
const TYPECONST = 'ATOM';
|
||||||
|
|
||||||
public function getTypeName() {
|
public function getTypeName() {
|
||||||
return pht('Atom');
|
return pht('Diviner Atom');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newObject() {
|
public function newObject() {
|
||||||
|
@ -28,8 +28,17 @@ final class DivinerAtomPHIDType extends PhabricatorPHIDType {
|
||||||
foreach ($handles as $phid => $handle) {
|
foreach ($handles as $phid => $handle) {
|
||||||
$atom = $objects[$phid];
|
$atom = $objects[$phid];
|
||||||
|
|
||||||
$handle->setName($atom->getTitle());
|
$book = $atom->getBook()->getName();
|
||||||
$handle->setURI($atom->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';
|
const TYPECONST = 'BOOK';
|
||||||
|
|
||||||
public function getTypeName() {
|
public function getTypeName() {
|
||||||
return pht('Book');
|
return pht('Diviner Book');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newObject() {
|
public function newObject() {
|
||||||
|
@ -30,9 +30,10 @@ final class DivinerBookPHIDType extends PhabricatorPHIDType {
|
||||||
|
|
||||||
$name = $book->getName();
|
$name = $book->getName();
|
||||||
|
|
||||||
$handle->setName($book->getShortTitle());
|
$handle
|
||||||
$handle->setFullName($book->getTitle());
|
->setName($book->getShortTitle())
|
||||||
$handle->setURI("/diviner/book/{$name}/");
|
->setFullName($book->getTitle())
|
||||||
|
->setURI("/book/{$name}/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,9 @@ final class DivinerLivePublisher extends DivinerPublisher {
|
||||||
|
|
||||||
$book->setConfigurationData($this->getConfigurationData())->save();
|
$book->setConfigurationData($this->getConfigurationData())->save();
|
||||||
$this->book = $book;
|
$this->book = $book;
|
||||||
|
|
||||||
|
id(new PhabricatorSearchIndexer())
|
||||||
|
->queueDocumentForIndexing($book->getPHID());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->book;
|
return $this->book;
|
||||||
|
@ -122,6 +125,9 @@ final class DivinerLivePublisher extends DivinerPublisher {
|
||||||
|
|
||||||
$symbol->save();
|
$symbol->save();
|
||||||
|
|
||||||
|
id(new PhabricatorSearchIndexer())
|
||||||
|
->queueDocumentForIndexing($symbol->getPHID());
|
||||||
|
|
||||||
// TODO: We probably need a finer-grained sense of what "documentable"
|
// TODO: We probably need a finer-grained sense of what "documentable"
|
||||||
// atoms are. Neither files nor methods are currently considered
|
// atoms are. Neither files nor methods are currently considered
|
||||||
// documentable, but for different reasons: files appear nowhere, while
|
// 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() {
|
public function generatePHID() {
|
||||||
return PhabricatorPHID::generateNewPHID(
|
return PhabricatorPHID::generateNewPHID(DivinerBookPHIDType::TYPECONST);
|
||||||
DivinerBookPHIDType::TYPECONST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle() {
|
public function getTitle() {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
final class PhabricatorSearchRelationship {
|
final class PhabricatorSearchRelationship {
|
||||||
|
|
||||||
const RELATIONSHIP_AUTHOR = 'auth';
|
const RELATIONSHIP_AUTHOR = 'auth';
|
||||||
|
const RELATIONSHIP_BOOK = 'book';
|
||||||
const RELATIONSHIP_REVIEWER = 'revw';
|
const RELATIONSHIP_REVIEWER = 'revw';
|
||||||
const RELATIONSHIP_SUBSCRIBER = 'subs';
|
const RELATIONSHIP_SUBSCRIBER = 'subs';
|
||||||
const RELATIONSHIP_COMMENTER = 'comm';
|
const RELATIONSHIP_COMMENTER = 'comm';
|
||||||
|
|
Loading…
Add table
Reference in a new issue