mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 17:52:43 +01:00
Index users in search results.
Summary: Add users to the search results. I need to follow this up with a patch to make the search results stop being terrible. I'll do that. Test Plan: Searched for users, ran "reindex_all_users.php" Reviewed By: jungejason Reviewers: tomo, jungejason, aran CC: aran, jungejason Differential Revision: 508
This commit is contained in:
parent
9844bbb4f9
commit
a632b220a8
7 changed files with 90 additions and 2 deletions
32
scripts/search/reindex_all_users.php
Executable file
32
scripts/search/reindex_all_users.php
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
$root = dirname(dirname(dirname(__FILE__)));
|
||||
require_once $root.'/scripts/__init_script__.php';
|
||||
require_once $root.'/scripts/__init_env__.php';
|
||||
|
||||
$users = id(new PhabricatorUser())->loadAll();
|
||||
echo "Indexing ".count($users)." users";
|
||||
foreach ($users as $user) {
|
||||
PhabricatorSearchUserIndexer::indexUser($user);
|
||||
echo '.';
|
||||
}
|
||||
echo "\n";
|
||||
echo "Done.\n";
|
||||
|
|
@ -493,6 +493,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorSearchQuery' => 'applications/search/storage/query',
|
||||
'PhabricatorSearchRelationship' => 'applications/search/constants/relationship',
|
||||
'PhabricatorSearchSelectController' => 'applications/search/controller/select',
|
||||
'PhabricatorSearchUserIndexer' => 'applications/search/index/indexer/user',
|
||||
'PhabricatorSetup' => 'infrastructure/setup',
|
||||
'PhabricatorStandardPageView' => 'view/page/standard',
|
||||
'PhabricatorStatusController' => 'applications/status/base',
|
||||
|
@ -951,6 +952,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorSearchMySQLExecutor' => 'PhabricatorSearchExecutor',
|
||||
'PhabricatorSearchQuery' => 'PhabricatorSearchDAO',
|
||||
'PhabricatorSearchSelectController' => 'PhabricatorSearchController',
|
||||
'PhabricatorSearchUserIndexer' => 'PhabricatorSearchDocumentIndexer',
|
||||
'PhabricatorStandardPageView' => 'AphrontPageView',
|
||||
'PhabricatorStatusController' => 'PhabricatorController',
|
||||
'PhabricatorTaskmasterDaemon' => 'PhabricatorDaemon',
|
||||
|
|
|
@ -10,7 +10,6 @@ phutil_require_module('phabricator', 'applications/conduit/method/base');
|
|||
phutil_require_module('phabricator', 'applications/conduit/protocol/exception');
|
||||
phutil_require_module('phabricator', 'applications/conduit/storage/connectionlog');
|
||||
phutil_require_module('phabricator', 'applications/people/storage/user');
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
|
|
@ -79,7 +79,11 @@ class PhabricatorUser extends PhabricatorUserDAO {
|
|||
if (!$this->conduitCertificate) {
|
||||
$this->conduitCertificate = $this->generateConduitCertificate();
|
||||
}
|
||||
return parent::save();
|
||||
$result = parent::save();
|
||||
|
||||
PhabricatorSearchUserIndexer::indexUser($this);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function generateConduitCertificate() {
|
||||
|
|
|
@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'applications/people/storage/log');
|
|||
phutil_require_module('phabricator', 'applications/people/storage/preferences');
|
||||
phutil_require_module('phabricator', 'applications/phid/constants');
|
||||
phutil_require_module('phabricator', 'applications/phid/storage/phid');
|
||||
phutil_require_module('phabricator', 'applications/search/index/indexer/user');
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
phutil_require_module('phabricator', 'storage/queryfx');
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class PhabricatorSearchUserIndexer
|
||||
extends PhabricatorSearchDocumentIndexer {
|
||||
|
||||
public static function indexUser(PhabricatorUser $user) {
|
||||
$doc = new PhabricatorSearchAbstractDocument();
|
||||
$doc->setPHID($user->getPHID());
|
||||
$doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_USER);
|
||||
$doc->setDocumentTitle($user->getUserName().'('.$user->getRealName().')');
|
||||
$doc->setDocumentCreated($user->getDateCreated());
|
||||
$doc->setDocumentModified($user->getDateModified());
|
||||
|
||||
// TODO: Index the blurbs from their profile or something? Probably not
|
||||
// actually useful...
|
||||
|
||||
PhabricatorSearchDocument::reindexAbstractDocument($doc);
|
||||
}
|
||||
}
|
15
src/applications/search/index/indexer/user/__init__.php
Normal file
15
src/applications/search/index/indexer/user/__init__.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/phid/constants');
|
||||
phutil_require_module('phabricator', 'applications/search/index/abstractdocument');
|
||||
phutil_require_module('phabricator', 'applications/search/index/indexer/base');
|
||||
phutil_require_module('phabricator', 'applications/search/storage/document/document');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorSearchUserIndexer.php');
|
Loading…
Reference in a new issue