@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+93 -9
+5
src/__phutil_library_map__.php
··· 642 642 'DivinerAtomQuery' => 'applications/diviner/query/DivinerAtomQuery.php', 643 643 'DivinerAtomRef' => 'applications/diviner/atom/DivinerAtomRef.php', 644 644 'DivinerAtomSearchEngine' => 'applications/diviner/query/DivinerAtomSearchEngine.php', 645 + 'DivinerAtomSearchIndexer' => 'applications/diviner/search/DivinerAtomSearchIndexer.php', 645 646 'DivinerAtomizeWorkflow' => 'applications/diviner/workflow/DivinerAtomizeWorkflow.php', 646 647 'DivinerAtomizer' => 'applications/diviner/atomizer/DivinerAtomizer.php', 647 648 'DivinerBookController' => 'applications/diviner/controller/DivinerBookController.php', 648 649 'DivinerBookItemView' => 'applications/diviner/view/DivinerBookItemView.php', 649 650 'DivinerBookPHIDType' => 'applications/diviner/phid/DivinerBookPHIDType.php', 650 651 'DivinerBookQuery' => 'applications/diviner/query/DivinerBookQuery.php', 652 + 'DivinerBookSearchIndexer' => 'applications/diviner/search/DivinerBookSearchIndexer.php', 651 653 'DivinerController' => 'applications/diviner/controller/DivinerController.php', 652 654 'DivinerDAO' => 'applications/diviner/storage/DivinerDAO.php', 653 655 'DivinerDefaultRenderer' => 'applications/diviner/renderer/DivinerDefaultRenderer.php', ··· 3884 3886 'DivinerAtomPHIDType' => 'PhabricatorPHIDType', 3885 3887 'DivinerAtomQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 3886 3888 'DivinerAtomSearchEngine' => 'PhabricatorApplicationSearchEngine', 3889 + 'DivinerAtomSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 3887 3890 'DivinerAtomizeWorkflow' => 'DivinerWorkflow', 3888 3891 'DivinerBookController' => 'DivinerController', 3889 3892 'DivinerBookItemView' => 'AphrontTagView', 3890 3893 'DivinerBookPHIDType' => 'PhabricatorPHIDType', 3891 3894 'DivinerBookQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 3895 + 'DivinerBookSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 3892 3896 'DivinerController' => 'PhabricatorController', 3893 3897 'DivinerDAO' => 'PhabricatorLiskDAO', 3894 3898 'DivinerDefaultRenderer' => 'DivinerRenderer', ··· 3899 3903 'DivinerLiveBook' => array( 3900 3904 'DivinerDAO', 3901 3905 'PhabricatorPolicyInterface', 3906 + 'PhabricatorProjectInterface', 3902 3907 'PhabricatorDestructibleInterface', 3903 3908 ), 3904 3909 'DivinerLivePublisher' => 'DivinerPublisher',
+7
src/applications/diviner/application/PhabricatorDivinerApplication.php
··· 58 58 ); 59 59 } 60 60 61 + public function getApplicationSearchDocumentTypes() { 62 + return array( 63 + DivinerAtomPHIDType::TYPECONST, 64 + DivinerBookPHIDType::TYPECONST, 65 + ); 66 + } 67 + 61 68 }
+12 -3
src/applications/diviner/phid/DivinerAtomPHIDType.php
··· 5 5 const TYPECONST = 'ATOM'; 6 6 7 7 public function getTypeName() { 8 - return pht('Atom'); 8 + return pht('Diviner Atom'); 9 9 } 10 10 11 11 public function newObject() { ··· 28 28 foreach ($handles as $phid => $handle) { 29 29 $atom = $objects[$phid]; 30 30 31 - $handle->setName($atom->getTitle()); 32 - $handle->setURI($atom->getName()); 31 + $book = $atom->getBook()->getName(); 32 + $name = $atom->getName(); 33 + $type = $atom->getType(); 34 + 35 + $handle 36 + ->setName($atom->getName()) 37 + ->setTitle($atom->getTitle()) 38 + ->setURI("/book/{$book}/{$type}/{$name}/") 39 + ->setStatus($atom->getGraphHash() 40 + ? PhabricatorObjectHandle::STATUS_OPEN 41 + : PhabricatorObjectHandle::STATUS_CLOSED); 33 42 } 34 43 } 35 44
+5 -4
src/applications/diviner/phid/DivinerBookPHIDType.php
··· 5 5 const TYPECONST = 'BOOK'; 6 6 7 7 public function getTypeName() { 8 - return pht('Book'); 8 + return pht('Diviner Book'); 9 9 } 10 10 11 11 public function newObject() { ··· 30 30 31 31 $name = $book->getName(); 32 32 33 - $handle->setName($book->getShortTitle()); 34 - $handle->setFullName($book->getTitle()); 35 - $handle->setURI("/diviner/book/{$name}/"); 33 + $handle 34 + ->setName($book->getShortTitle()) 35 + ->setFullName($book->getTitle()) 36 + ->setURI("/book/{$name}/"); 36 37 } 37 38 } 38 39
+6
src/applications/diviner/publisher/DivinerLivePublisher.php
··· 18 18 19 19 $book->setConfigurationData($this->getConfigurationData())->save(); 20 20 $this->book = $book; 21 + 22 + id(new PhabricatorSearchIndexer()) 23 + ->queueDocumentForIndexing($book->getPHID()); 21 24 } 22 25 23 26 return $this->book; ··· 121 124 } 122 125 123 126 $symbol->save(); 127 + 128 + id(new PhabricatorSearchIndexer()) 129 + ->queueDocumentForIndexing($symbol->getPHID()); 124 130 125 131 // TODO: We probably need a finer-grained sense of what "documentable" 126 132 // atoms are. Neither files nor methods are currently considered
+31
src/applications/diviner/search/DivinerAtomSearchIndexer.php
··· 1 + <?php 2 + 3 + final class DivinerAtomSearchIndexer extends PhabricatorSearchDocumentIndexer { 4 + 5 + public function getIndexableObject() { 6 + return new DivinerLiveSymbol(); 7 + } 8 + 9 + protected function buildAbstractDocumentByPHID($phid) { 10 + $atom = $this->loadDocumentByPHID($phid); 11 + $book = $atom->getBook(); 12 + 13 + $doc = $this->newDocument($phid) 14 + ->setDocumentTitle($atom->getTitle()) 15 + ->setDocumentCreated($book->getDateCreated()) 16 + ->setDocumentModified($book->getDateModified()); 17 + 18 + $doc->addField( 19 + PhabricatorSearchField::FIELD_BODY, 20 + $atom->getSummary()); 21 + 22 + $doc->addRelationship( 23 + PhabricatorSearchRelationship::RELATIONSHIP_BOOK, 24 + $atom->getBookPHID(), 25 + DivinerBookPHIDType::TYPECONST, 26 + $book->getDateCreated()); 27 + 28 + return $doc; 29 + } 30 + 31 + }
+25
src/applications/diviner/search/DivinerBookSearchIndexer.php
··· 1 + <?php 2 + 3 + final class DivinerBookSearchIndexer extends PhabricatorSearchDocumentIndexer { 4 + 5 + public function getIndexableObject() { 6 + return new DivinerLiveBook(); 7 + } 8 + 9 + protected function buildAbstractDocumentByPHID($phid) { 10 + $book = $this->loadDocumentByPHID($phid); 11 + 12 + $doc = $this->newDocument($phid) 13 + ->setDocumentTitle($book->getTitle()) 14 + ->setDocumentCreated($book->getDateCreated()) 15 + ->setDocumentModified($book->getDateModified()); 16 + 17 + $doc->addField( 18 + PhabricatorSearchField::FIELD_BODY, 19 + $book->getPreface()); 20 + 21 + return $doc; 22 + } 23 + 24 + 25 + }
+1 -2
src/applications/diviner/storage/DivinerLiveBook.php
··· 42 42 } 43 43 44 44 public function generatePHID() { 45 - return PhabricatorPHID::generateNewPHID( 46 - DivinerBookPHIDType::TYPECONST); 45 + return PhabricatorPHID::generateNewPHID(DivinerBookPHIDType::TYPECONST); 47 46 } 48 47 49 48 public function getTitle() {
+1
src/applications/search/constants/PhabricatorSearchRelationship.php
··· 3 3 final class PhabricatorSearchRelationship { 4 4 5 5 const RELATIONSHIP_AUTHOR = 'auth'; 6 + const RELATIONSHIP_BOOK = 'book'; 6 7 const RELATIONSHIP_REVIEWER = 'revw'; 7 8 const RELATIONSHIP_SUBSCRIBER = 'subs'; 8 9 const RELATIONSHIP_COMMENTER = 'comm';