mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-01 17:38:24 +01:00
6e57582aff
Summary: Ref T11404. Currently, SearchEngineAttachments can bulk-load data but SearchEngineExtensions can not. This leads to poor performance of custom fields. See T11404 for discussion. This changes the API to support a bulk load + format pattern like the one Attachments use. The next change will use it to bulk-load custom field data. Test Plan: - Ran `differential.query`, `differential.revision.search` as a sanity check. - No behavioral changes are expected - See next revision. Reviewers: yelirekim, chad Reviewed By: chad Maniphest Tasks: T11404 Differential Revision: https://secure.phabricator.com/D16350
72 lines
1.8 KiB
PHP
72 lines
1.8 KiB
PHP
<?php
|
|
|
|
final class PhabricatorSpacesSearchEngineExtension
|
|
extends PhabricatorSearchEngineExtension {
|
|
|
|
const EXTENSIONKEY = 'spaces';
|
|
|
|
public function isExtensionEnabled() {
|
|
return PhabricatorApplication::isClassInstalled(
|
|
'PhabricatorSpacesApplication');
|
|
}
|
|
|
|
public function getExtensionName() {
|
|
return pht('Support for Spaces');
|
|
}
|
|
|
|
public function getExtensionOrder() {
|
|
return 4000;
|
|
}
|
|
|
|
public function supportsObject($object) {
|
|
return ($object instanceof PhabricatorSpacesInterface);
|
|
}
|
|
|
|
public function getSearchFields($object) {
|
|
$fields = array();
|
|
|
|
if (PhabricatorSpacesNamespaceQuery::getSpacesExist()) {
|
|
$fields[] = id(new PhabricatorSpacesSearchField())
|
|
->setKey('spacePHIDs')
|
|
->setConduitKey('spaces')
|
|
->setAliases(array('space', 'spaces'))
|
|
->setLabel(pht('Spaces'))
|
|
->setDescription(
|
|
pht('Search for objects in certain spaces.'));
|
|
}
|
|
|
|
return $fields;
|
|
}
|
|
|
|
public function applyConstraintsToQuery(
|
|
$object,
|
|
$query,
|
|
PhabricatorSavedQuery $saved,
|
|
array $map) {
|
|
|
|
if (!empty($map['spacePHIDs'])) {
|
|
$query->withSpacePHIDs($map['spacePHIDs']);
|
|
} else {
|
|
// If the user doesn't search for objects in specific spaces, we
|
|
// default to "all active spaces you have permission to view".
|
|
$query->withSpaceIsArchived(false);
|
|
}
|
|
}
|
|
|
|
public function getFieldSpecificationsForConduit($object) {
|
|
return array(
|
|
id(new PhabricatorConduitSearchFieldSpecification())
|
|
->setKey('spacePHID')
|
|
->setType('phid?')
|
|
->setDescription(
|
|
pht('PHID of the policy space this object is part of.')),
|
|
);
|
|
}
|
|
|
|
public function getFieldValuesForConduit($object, $data) {
|
|
return array(
|
|
'spacePHID' => $object->getSpacePHID(),
|
|
);
|
|
}
|
|
|
|
}
|