Skip to content
Snippets Groups Projects
Commit b5c9a8a4 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Add sort for all queries with limit

parent 5da434b6
Loading
......@@ -9,6 +9,8 @@ Meteor.publish 'channelAutocomplete', (name) ->
_id: 1
name: 1
limit: 5
sort:
name: 1
cursorHandle = RocketChat.models.Rooms.findByNameContainingAndTypes(name, ['c'], options).observeChanges
added: (_id, record) ->
......
......@@ -12,7 +12,7 @@ Meteor.publish 'roomSearch', (selector, options, collName) ->
delete selector.type
if not searchType? or searchType is 'u'
subHandleUsers = RocketChat.models.Users.find(selector, { limit: 10, fields: { name: 1, username: 1, status: 1 } }).observeChanges
subHandleUsers = RocketChat.models.Users.find(selector, { limit: 10, fields: { name: 1, username: 1, status: 1 }, sort: { name: 1 } }).observeChanges
added: (id, fields) ->
data = { type: 'u', uid: id, name: fields.name, username: fields.username, status: fields.status }
self.added("autocompleteRecords", id, data)
......@@ -22,7 +22,7 @@ Meteor.publish 'roomSearch', (selector, options, collName) ->
self.removed("autocompleteRecords", id)
if not searchType? or searchType is 'r'
subHandleRooms = RocketChat.models.Rooms.findByTypesAndNotUserIdContainingUsername(RocketChat.roomTypes.getIdentifiers('d'), selector.uid?.$ne, RocketChat.models.Users.findOneById(this.userId).username, { limit: 10, fields: { t: 1, name: 1 } }).observeChanges
subHandleRooms = RocketChat.models.Rooms.findByTypesAndNotUserIdContainingUsername(RocketChat.roomTypes.getIdentifiers('d'), selector.uid?.$ne, RocketChat.models.Users.findOneById(this.userId).username, { limit: 10, fields: { t: 1, name: 1 }, sort: { name: 1 } }).observeChanges
added: (id, fields) ->
data = { type: 'r', rid: id, name: fields.name, t: fields.t }
self.added("autocompleteRecords", id, data)
......
......@@ -6,7 +6,7 @@ Meteor.publish 'spotlight', (selector, options, collName) ->
subHandleUsers = null
subHandleRooms = null
subHandleUsers = RocketChat.models.Users.findUsersByNameOrUsername(new RegExp(selector.name.$regex, 'i'), { limit: 10, fields: { name: 1, username: 1, status: 1 } }).observeChanges
subHandleUsers = RocketChat.models.Users.findUsersByNameOrUsername(new RegExp(selector.name.$regex, 'i'), { limit: 10, fields: { name: 1, username: 1, status: 1 }, sort: { name: 1 } }).observeChanges
added: (id, fields) ->
data = { type: 'u', uid: id, name: fields.username + ' - ' + fields.name, status: fields.status }
self.added("autocompleteRecords", id, data)
......
......@@ -10,6 +10,8 @@ Meteor.publish 'userAutocomplete', (selector) ->
username: 1
status: 1
limit: 10
sort:
name: 1
exceptions = selector.exceptions or []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment