@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.

at upstream/main 61 lines 1.7 kB view raw
1<?php 2 3final class PhabricatorTransactionsFulltextEngineExtension 4 extends PhabricatorFulltextEngineExtension { 5 6 const EXTENSIONKEY = 'transactions'; 7 8 public function getExtensionName() { 9 return pht('Comments'); 10 } 11 12 public function shouldEnrichFulltextObject($object) { 13 return ($object instanceof PhabricatorApplicationTransactionInterface); 14 } 15 16 public function enrichFulltextObject( 17 $object, 18 PhabricatorSearchAbstractDocument $document) { 19 20 $query = PhabricatorApplicationTransactionQuery::newQueryForObject($object); 21 if (!$query) { 22 return; 23 } 24 25 $query 26 ->setViewer($this->getViewer()) 27 ->withObjectPHIDs(array($object->getPHID())) 28 ->withComments(true) 29 ->needComments(true); 30 31 // See PHI719. Users occasionally create objects with huge numbers of 32 // comments, which can be slow to index. We handle this with reasonable 33 // grace: at time of writing, we can index a task with 100K comments in 34 // about 30 seconds. However, we do need to hold all the comments in 35 // memory in the AbstractDocument, so there's some practical limit to what 36 // we can realistically index. 37 38 // Since objects with more than 1,000 comments are not likely to be 39 // legitimate objects with actual discussion, index only the first 40 // thousand comments. 41 42 $query 43 ->setOrderVector(array('-id')) 44 ->setLimit(1000); 45 46 $xactions = $query->execute(); 47 48 foreach ($xactions as $xaction) { 49 if (!$xaction->hasComment()) { 50 continue; 51 } 52 53 $comment = $xaction->getComment(); 54 55 $document->addField( 56 PhabricatorSearchDocumentFieldType::FIELD_COMMENT, 57 $comment->getContent()); 58 } 59 } 60 61}