From bce44c8b02b312fa3cb5cc9e144dda7593ef4734 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Tue, 14 Jun 2016 12:17:09 -0700 Subject: [PATCH] Add PhamePost to full text search Summary: Adds PhamePost object to fulltextsearch index. Some issue searching just "Open" though? Also "closed" objects search fine but don't display as disabled. Test Plan: bin/search index --type POST {F1687043} Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T9897 Differential Revision: https://secure.phabricator.com/D16116 --- src/__phutil_library_map__.php | 3 ++ .../phid/PhabricatorPhamePostPHIDType.php | 6 ++++ .../phame/search/PhamePostFulltextEngine.php | 34 +++++++++++++++++++ src/applications/phame/storage/PhamePost.php | 10 +++++- 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/applications/phame/search/PhamePostFulltextEngine.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 4f5eb4caa6..971b9be04c 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3792,6 +3792,7 @@ phutil_register_library_map(array( 'PhamePostEditController' => 'applications/phame/controller/post/PhamePostEditController.php', 'PhamePostEditEngine' => 'applications/phame/editor/PhamePostEditEngine.php', 'PhamePostEditor' => 'applications/phame/editor/PhamePostEditor.php', + 'PhamePostFulltextEngine' => 'applications/phame/search/PhamePostFulltextEngine.php', 'PhamePostHistoryController' => 'applications/phame/controller/post/PhamePostHistoryController.php', 'PhamePostListController' => 'applications/phame/controller/post/PhamePostListController.php', 'PhamePostListView' => 'applications/phame/view/PhamePostListView.php', @@ -8655,6 +8656,7 @@ phutil_register_library_map(array( 'PhabricatorDestructibleInterface', 'PhabricatorTokenReceiverInterface', 'PhabricatorConduitResultInterface', + 'PhabricatorFulltextInterface', ), 'PhamePostArchiveController' => 'PhamePostController', 'PhamePostCommentController' => 'PhamePostController', @@ -8663,6 +8665,7 @@ phutil_register_library_map(array( 'PhamePostEditController' => 'PhamePostController', 'PhamePostEditEngine' => 'PhabricatorEditEngine', 'PhamePostEditor' => 'PhabricatorApplicationTransactionEditor', + 'PhamePostFulltextEngine' => 'PhabricatorFulltextEngine', 'PhamePostHistoryController' => 'PhamePostController', 'PhamePostListController' => 'PhamePostController', 'PhamePostListView' => 'AphrontTagView', diff --git a/src/applications/phame/phid/PhabricatorPhamePostPHIDType.php b/src/applications/phame/phid/PhabricatorPhamePostPHIDType.php index 5573f2db9f..4250c91949 100644 --- a/src/applications/phame/phid/PhabricatorPhamePostPHIDType.php +++ b/src/applications/phame/phid/PhabricatorPhamePostPHIDType.php @@ -34,7 +34,13 @@ final class PhabricatorPhamePostPHIDType extends PhabricatorPHIDType { $handle->setName($post->getTitle()); $handle->setFullName($post->getTitle()); $handle->setURI('/phame/post/view/'.$post->getID().'/'); + + if ($post->isArchived()) { + $handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED); + } + } + } } diff --git a/src/applications/phame/search/PhamePostFulltextEngine.php b/src/applications/phame/search/PhamePostFulltextEngine.php new file mode 100644 index 0000000000..27a97ae4ba --- /dev/null +++ b/src/applications/phame/search/PhamePostFulltextEngine.php @@ -0,0 +1,34 @@ +setDocumentTitle($post->getTitle()); + + $document->addField( + PhabricatorSearchDocumentFieldType::FIELD_BODY, + $post->getBody()); + + $document->addRelationship( + PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, + $post->getBloggerPHID(), + PhabricatorPeopleUserPHIDType::TYPECONST, + $post->getDateCreated()); + + $document->addRelationship( + $post->isArchived() + ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED + : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, + $post->getPHID(), + PhabricatorPhamePostPHIDType::TYPECONST, + PhabricatorTime::getNow()); + + } + +} diff --git a/src/applications/phame/storage/PhamePost.php b/src/applications/phame/storage/PhamePost.php index f77032ffab..2d8fc887c5 100644 --- a/src/applications/phame/storage/PhamePost.php +++ b/src/applications/phame/storage/PhamePost.php @@ -10,7 +10,8 @@ final class PhamePost extends PhameDAO PhabricatorSubscribableInterface, PhabricatorDestructibleInterface, PhabricatorTokenReceiverInterface, - PhabricatorConduitResultInterface { + PhabricatorConduitResultInterface, + PhabricatorFulltextInterface { const MARKUP_FIELD_BODY = 'markup:body'; const MARKUP_FIELD_SUMMARY = 'markup:summary'; @@ -344,4 +345,11 @@ final class PhamePost extends PhameDAO return array(); } + +/* -( PhabricatorFulltextInterface )--------------------------------------- */ + + public function newFulltextEngine() { + return new PhamePostFulltextEngine(); + } + }