Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15504195
D17597.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D17597.diff
View Options
diff --git a/src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php b/src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php
--- a/src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php
+++ b/src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php
@@ -87,8 +87,9 @@
}
if (!$is_background) {
- $console->writeOut(
- "%s\n",
+ echo tsprintf(
+ "**<bg:blue> %s </bg>** %s\n",
+ pht('NOTE'),
pht(
'Run this workflow with "%s" to queue tasks for the daemon workers.',
'--background'));
@@ -109,9 +110,32 @@
);
$any_success = false;
+
+ // If we aren't using "--background" or "--force", track how many objects
+ // we're skipping so we can print this information for the user and give
+ // them a hint that they might want to use "--force".
+ $track_skips = (!$is_background && !$is_force);
+
+ $count_updated = 0;
+ $count_skipped = 0;
+
foreach ($phids as $phid) {
try {
+ if ($track_skips) {
+ $old_versions = $this->loadIndexVersions($phid);
+ }
+
PhabricatorSearchWorker::queueDocumentForIndexing($phid, $parameters);
+
+ if ($track_skips) {
+ $new_versions = $this->loadIndexVersions($phid);
+ if ($old_versions !== $new_versions) {
+ $count_updated++;
+ } else {
+ $count_skipped++;
+ }
+ }
+
$any_success = true;
} catch (Exception $ex) {
phlog($ex);
@@ -127,6 +151,45 @@
pht('Failed to rebuild search index for any documents.'));
}
+ if ($track_skips) {
+ if ($count_updated) {
+ echo tsprintf(
+ "**<bg:green> %s </bg>** %s\n",
+ pht('DONE'),
+ pht(
+ 'Updated search indexes for %s document(s).',
+ new PhutilNumber($count_updated)));
+ }
+
+ if ($count_skipped) {
+ echo tsprintf(
+ "**<bg:yellow> %s </bg>** %s\n",
+ pht('SKIP'),
+ pht(
+ 'Skipped %s documents(s) which have not updated since they were '.
+ 'last indexed.',
+ new PhutilNumber($count_skipped)));
+ echo tsprintf(
+ "**<bg:blue> %s </bg>** %s\n",
+ pht('NOTE'),
+ pht(
+ 'Use "--force" to force the index to update these documents.'));
+ }
+ } else if ($is_background) {
+ echo tsprintf(
+ "**<bg:green> %s </bg>** %s\n",
+ pht('DONE'),
+ pht(
+ 'Queued %s document(s) for background indexing.',
+ new PhutilNumber(count($phids))));
+ } else {
+ echo tsprintf(
+ "**<bg:green> %s </bg>** %s\n",
+ pht('DONE'),
+ pht(
+ 'Forced search index updates for %s document(s).',
+ new PhutilNumber(count($phids))));
+ }
}
private function loadPHIDsByNames(array $names) {
@@ -206,5 +269,16 @@
return $phids;
}
+ private function loadIndexVersions($phid) {
+ $table = new PhabricatorSearchIndexVersion();
+ $conn = $table->establishConnection('r');
+
+ return queryfx_all(
+ $conn,
+ 'SELECT extensionKey, version FROM %T WHERE objectPHID = %s
+ ORDER BY extensionKey, version',
+ $table->getTableName(),
+ $phid);
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 15, 4:36 PM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7386580
Default Alt Text
D17597.diff (3 KB)
Attached To
Mode
D17597: Count and report skipped documents from "bin/search index"
Attached
Detach File
Event Timeline
Log In to Comment