1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-01 11:12:42 +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:
epriestley 2011-06-23 13:31:20 -07:00
parent 9844bbb4f9
commit a632b220a8
7 changed files with 90 additions and 2 deletions

View 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";

View file

@ -493,6 +493,7 @@ phutil_register_library_map(array(
'PhabricatorSearchQuery' => 'applications/search/storage/query', 'PhabricatorSearchQuery' => 'applications/search/storage/query',
'PhabricatorSearchRelationship' => 'applications/search/constants/relationship', 'PhabricatorSearchRelationship' => 'applications/search/constants/relationship',
'PhabricatorSearchSelectController' => 'applications/search/controller/select', 'PhabricatorSearchSelectController' => 'applications/search/controller/select',
'PhabricatorSearchUserIndexer' => 'applications/search/index/indexer/user',
'PhabricatorSetup' => 'infrastructure/setup', 'PhabricatorSetup' => 'infrastructure/setup',
'PhabricatorStandardPageView' => 'view/page/standard', 'PhabricatorStandardPageView' => 'view/page/standard',
'PhabricatorStatusController' => 'applications/status/base', 'PhabricatorStatusController' => 'applications/status/base',
@ -951,6 +952,7 @@ phutil_register_library_map(array(
'PhabricatorSearchMySQLExecutor' => 'PhabricatorSearchExecutor', 'PhabricatorSearchMySQLExecutor' => 'PhabricatorSearchExecutor',
'PhabricatorSearchQuery' => 'PhabricatorSearchDAO', 'PhabricatorSearchQuery' => 'PhabricatorSearchDAO',
'PhabricatorSearchSelectController' => 'PhabricatorSearchController', 'PhabricatorSearchSelectController' => 'PhabricatorSearchController',
'PhabricatorSearchUserIndexer' => 'PhabricatorSearchDocumentIndexer',
'PhabricatorStandardPageView' => 'AphrontPageView', 'PhabricatorStandardPageView' => 'AphrontPageView',
'PhabricatorStatusController' => 'PhabricatorController', 'PhabricatorStatusController' => 'PhabricatorController',
'PhabricatorTaskmasterDaemon' => 'PhabricatorDaemon', 'PhabricatorTaskmasterDaemon' => 'PhabricatorDaemon',

View file

@ -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/protocol/exception');
phutil_require_module('phabricator', 'applications/conduit/storage/connectionlog'); phutil_require_module('phabricator', 'applications/conduit/storage/connectionlog');
phutil_require_module('phabricator', 'applications/people/storage/user'); phutil_require_module('phabricator', 'applications/people/storage/user');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -79,7 +79,11 @@ class PhabricatorUser extends PhabricatorUserDAO {
if (!$this->conduitCertificate) { if (!$this->conduitCertificate) {
$this->conduitCertificate = $this->generateConduitCertificate(); $this->conduitCertificate = $this->generateConduitCertificate();
} }
return parent::save(); $result = parent::save();
PhabricatorSearchUserIndexer::indexUser($this);
return $result;
} }
private function generateConduitCertificate() { private function generateConduitCertificate() {

View file

@ -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/people/storage/preferences');
phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phabricator', 'applications/phid/storage/phid'); 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', 'infrastructure/env');
phutil_require_module('phabricator', 'storage/queryfx'); phutil_require_module('phabricator', 'storage/queryfx');

View file

@ -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);
}
}

View 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');