mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Reindex dashboards and panels (allow migrations to queue a job to queue other indexing jobs)
Summary: Depends on D20411. Ref T13272. Dashboards and panels have new indexes (Ferret and usage edges) that need a rebuild. For large datasets like commits we have the "activity" flow in T11932, but realistically these rebuilds won't take more than a few minutes on any realistic install so we should be able to just queue them up as migrations. Let migrations insert a job to basically run `bin/search index --type SomeObjectType`, then do that for dashboards and panels. (I'll do Herald rules in a followup too, but I want to tweak one indexing thing there.) Test Plan: Ran the migration, ran `bin/phd debug task`, saw everything get indexed with no manual intervention. Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13272 Differential Revision: https://secure.phabricator.com/D20412
This commit is contained in:
parent
0583f6dc50
commit
4eab3c4c8d
4 changed files with 67 additions and 0 deletions
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
PhabricatorRebuildIndexesWorker::rebuildObjectsWithQuery(
|
||||
'PhabricatorDashboardQuery');
|
||||
|
||||
PhabricatorRebuildIndexesWorker::rebuildObjectsWithQuery(
|
||||
'PhabricatorDashboardPanelQuery');
|
|
@ -4294,6 +4294,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorQueryOrderVector' => 'infrastructure/query/order/PhabricatorQueryOrderVector.php',
|
||||
'PhabricatorQuickSearchEngineExtension' => 'applications/search/engineextension/PhabricatorQuickSearchEngineExtension.php',
|
||||
'PhabricatorRateLimitRequestExceptionHandler' => 'aphront/handler/PhabricatorRateLimitRequestExceptionHandler.php',
|
||||
'PhabricatorRebuildIndexesWorker' => 'applications/search/worker/PhabricatorRebuildIndexesWorker.php',
|
||||
'PhabricatorRecaptchaConfigOptions' => 'applications/config/option/PhabricatorRecaptchaConfigOptions.php',
|
||||
'PhabricatorRedirectController' => 'applications/base/controller/PhabricatorRedirectController.php',
|
||||
'PhabricatorRefreshCSRFController' => 'applications/auth/controller/PhabricatorRefreshCSRFController.php',
|
||||
|
@ -10503,6 +10504,7 @@ phutil_register_library_map(array(
|
|||
),
|
||||
'PhabricatorQuickSearchEngineExtension' => 'PhabricatorDatasourceEngineExtension',
|
||||
'PhabricatorRateLimitRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler',
|
||||
'PhabricatorRebuildIndexesWorker' => 'PhabricatorWorker',
|
||||
'PhabricatorRecaptchaConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||
'PhabricatorRedirectController' => 'PhabricatorController',
|
||||
'PhabricatorRefreshCSRFController' => 'PhabricatorAuthController',
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorRebuildIndexesWorker extends PhabricatorWorker {
|
||||
|
||||
public static function rebuildObjectsWithQuery($query_class) {
|
||||
parent::scheduleTask(
|
||||
__CLASS__,
|
||||
array(
|
||||
'queryClass' => $query_class,
|
||||
),
|
||||
array(
|
||||
'priority' => parent::PRIORITY_INDEX,
|
||||
));
|
||||
}
|
||||
|
||||
protected function doWork() {
|
||||
$viewer = PhabricatorUser::getOmnipotentUser();
|
||||
|
||||
$data = $this->getTaskData();
|
||||
$query_class = idx($data, 'queryClass');
|
||||
|
||||
try {
|
||||
$query = newv($query_class, array());
|
||||
} catch (Exception $ex) {
|
||||
throw new PhabricatorWorkerPermanentFailureException(
|
||||
pht(
|
||||
'Unable to instantiate query class "%s": %s',
|
||||
$query_class,
|
||||
$ex->getMessage()));
|
||||
}
|
||||
|
||||
$query->setViewer($viewer);
|
||||
|
||||
$iterator = new PhabricatorQueryIterator($query);
|
||||
foreach ($iterator as $object) {
|
||||
PhabricatorSearchWorker::queueDocumentForIndexing(
|
||||
$object->getPHID(),
|
||||
array(
|
||||
'force' => true,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -8,6 +8,20 @@ final class PhabricatorWorkerTestCase extends PhabricatorTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
protected function willRunOneTest($test) {
|
||||
parent::willRunOneTest($test);
|
||||
|
||||
// Before we run these test cases, clear the queue. After D20412, we may
|
||||
// have queued tasks from migrations.
|
||||
$task_table = new PhabricatorWorkerActiveTask();
|
||||
$conn = $task_table->establishConnection('w');
|
||||
|
||||
queryfx(
|
||||
$conn,
|
||||
'TRUNCATE %R',
|
||||
$task_table);
|
||||
}
|
||||
|
||||
public function testLeaseTask() {
|
||||
$task = $this->scheduleTask();
|
||||
$this->expectNextLease($task, pht('Leasing should work.'));
|
||||
|
|
Loading…
Reference in a new issue