3 final class PhabricatorSearchFerretNgramGarbageCollector
4 extends PhabricatorGarbageCollector
{
6 const COLLECTORCONST
= 'search.ferret.ngram';
8 public function getCollectorName() {
9 return pht('Ferret Engine Ngrams');
12 public function hasAutomaticPolicy() {
16 protected function collectGarbage() {
17 $all_objects = id(new PhutilClassMapQuery())
18 ->setAncestorClass('PhabricatorFerretInterface')
22 foreach ($all_objects as $object) {
23 $engine = $object->newFerretEngine();
24 $conn = $object->establishConnection('w');
26 $ngram_row = queryfx_one(
28 'SELECT ngram FROM %T WHERE needsCollection = 1 LIMIT 1',
29 $engine->getCommonNgramsTableName());
34 $ngram = $ngram_row['ngram'];
38 'DELETE FROM %T WHERE ngram = %s',
39 $engine->getNgramsTableName(),
44 'UPDATE %T SET needsCollection = 0 WHERE ngram = %s',
45 $engine->getCommonNgramsTableName(),