Merge pull request #18816 from nextcloud/bugfix/noid/paginate-contacts-search
Use paginated search for contacts
This commit is contained in:
commit
038045d55e
|
@ -105,6 +105,8 @@ class AddressBookImpl implements IAddressBook {
|
|||
* - 'types' boolean (since 15.0.0) If set to true, fields that come with a TYPE property will be an array
|
||||
* example: ['id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => ['type => 'HOME', 'value' => 'g@h.i']]
|
||||
* - 'escape_like_param' - If set to false wildcards _ and % are not escaped
|
||||
* - 'limit' - Set a numeric limit for the search results
|
||||
* - 'offset' - Set the offset for the limited search results
|
||||
* @return array an array of contacts which are arrays of key-value-pairs
|
||||
* example result:
|
||||
* [
|
||||
|
|
|
@ -965,6 +965,12 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
$query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%')));
|
||||
}
|
||||
}
|
||||
if (isset($options['limit'])) {
|
||||
$query2->setMaxResults($options['limit']);
|
||||
}
|
||||
if (isset($options['offset'])) {
|
||||
$query2->setFirstResult($options['offset']);
|
||||
}
|
||||
|
||||
$query->select('c.carddata', 'c.uri')->from($this->dbCardsTable, 'c')
|
||||
->where($query->expr()->in('c.id', $query->createFunction($query2->getSQL())));
|
||||
|
|
|
@ -81,8 +81,7 @@ class MailPlugin implements ISearchPlugin {
|
|||
$emailType = new SearchResultType('emails');
|
||||
|
||||
// Search in contacts
|
||||
//@todo Pagination missing
|
||||
$addressBookContacts = $this->contactsManager->search($search, ['EMAIL', 'FN']);
|
||||
$addressBookContacts = $this->contactsManager->search($search, ['EMAIL', 'FN'], ['limit' => $limit, 'offset' => $offset]);
|
||||
$lowerSearch = strtolower($search);
|
||||
foreach ($addressBookContacts as $contact) {
|
||||
if (isset($contact['EMAIL'])) {
|
||||
|
|
|
@ -67,8 +67,7 @@ class RemotePlugin implements ISearchPlugin {
|
|||
$resultType = new SearchResultType('remotes');
|
||||
|
||||
// Search in contacts
|
||||
//@todo Pagination missing
|
||||
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN']);
|
||||
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN'], ['limit' => $limit, 'offset' => $offset]);
|
||||
foreach ($addressBookContacts as $contact) {
|
||||
if (isset($contact['isLocalSystemBook'])) {
|
||||
continue;
|
||||
|
|
|
@ -40,6 +40,8 @@ namespace OC {
|
|||
* @param array $searchProperties defines the properties within the query pattern should match
|
||||
* @param array $options = array() to define the search behavior
|
||||
* - 'escape_like_param' - If set to false wildcards _ and % are not escaped
|
||||
* - 'limit' - Set a numeric limit for the search results
|
||||
* - 'offset' - Set the offset for the limited search results
|
||||
* @return array an array of contacts which are arrays of key-value-pairs
|
||||
*/
|
||||
public function search($pattern, $searchProperties = [], $options = []) {
|
||||
|
|
|
@ -96,6 +96,8 @@ interface IManager {
|
|||
* @param array $searchProperties defines the properties within the query pattern should match
|
||||
* @param array $options = array() to define the search behavior
|
||||
* - 'escape_like_param' - If set to false wildcards _ and % are not escaped
|
||||
* - 'limit' - Set a numeric limit for the search results
|
||||
* - 'offset' - Set the offset for the limited search results
|
||||
* @return array an array of contacts which are arrays of key-value-pairs
|
||||
* @since 6.0.0
|
||||
*/
|
||||
|
|
|
@ -71,6 +71,8 @@ namespace OCP {
|
|||
* - 'types' boolean (since 15.0.0) If set to true, fields that come with a TYPE property will be an array
|
||||
* example: ['id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => ['type => 'HOME', 'value' => 'g@h.i']]
|
||||
* - 'escape_like_param' - If set to false wildcards _ and % are not escaped
|
||||
* - 'limit' - Set a numeric limit for the search results
|
||||
* - 'offset' - Set the offset for the limited search results
|
||||
* @return array an array of contacts which are arrays of key-value-pairs
|
||||
* example result:
|
||||
* [
|
||||
|
|
Loading…
Reference in New Issue