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

Parameterize the common ngrams threshold

Summary:
Ref T13000. Since other changes have generally made the ngrams table manageable, I'm not planning to enable common ngrams by default at this time.

Instead, make the threshold configurable with "--threshold" so we can guide installs through tuning this if they want (e.g. PHI110), and tune hosted instances.

(This might eventually become automatic, but just smoothing this bit off for now feels reasonable to me.)

Test Plan: Ran with `--reset`, and with various invalid and valid `--threshold` arguments.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13000

Differential Revision: https://secure.phabricator.com/D18710

+33 -3
+33 -3
src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php
··· 16 16 'name' => 'reset', 17 17 'help' => pht('Reset all common ngram records.'), 18 18 ), 19 + array( 20 + 'name' => 'threshold', 21 + 'param' => 'threshold', 22 + 'help' => pht( 23 + 'Prune ngrams present in more than this fraction of '. 24 + 'documents.'), 25 + ), 19 26 )); 20 27 } 21 28 22 29 public function execute(PhutilArgumentParser $args) { 30 + $min_documents = 4096; 31 + 23 32 $is_reset = $args->getArg('reset'); 33 + $threshold = $args->getArg('threshold'); 34 + 35 + if ($is_reset && $threshold !== null) { 36 + throw new PhutilArgumentUsageException( 37 + pht('Specify either --reset or --threshold, not both.')); 38 + } 39 + 40 + if (!$is_reset && $threshold === null) { 41 + throw new PhutilArgumentUsageException( 42 + pht('Specify either --reset or --threshold.')); 43 + } 44 + 45 + if (!$is_reset) { 46 + if (!is_numeric($threshold)) { 47 + throw new PhutilArgumentUsageException( 48 + pht('Specify a numeric threshold between 0 and 1.')); 49 + } 50 + 51 + $threshold = (double)$threshold; 52 + if ($threshold <= 0 || $threshold >= 1) { 53 + throw new PhutilArgumentUsageException( 54 + pht('Threshold must be greater than 0.0 and less than 1.0.')); 55 + } 56 + } 24 57 25 58 $all_objects = id(new PhutilClassMapQuery()) 26 59 ->setAncestorClass('PhabricatorFerretInterface') 27 60 ->execute(); 28 - 29 - $min_documents = 4096; 30 - $threshold = 0.15; 31 61 32 62 foreach ($all_objects as $object) { 33 63 $engine = $object->newFerretEngine();