mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-11-01 23:55:58 +09:00
Improve 賢さ
This commit is contained in:
parent
83f2926f0c
commit
9536d76b61
@ -21,12 +21,36 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
|
||||
let users = await User
|
||||
.find({
|
||||
host: null,
|
||||
usernameLower: new RegExp(escapeRegexp(query.toLowerCase()))
|
||||
usernameLower: new RegExp('^' + escapeRegexp(query.toLowerCase()))
|
||||
}, {
|
||||
limit: limit,
|
||||
skip: offset
|
||||
});
|
||||
|
||||
if (users.length < limit) {
|
||||
const remoteUsers = await User
|
||||
.find({
|
||||
host: { $ne: null },
|
||||
usernameLower: new RegExp('^' + escapeRegexp(query.toLowerCase()))
|
||||
}, {
|
||||
limit: limit - users.length
|
||||
});
|
||||
|
||||
users = users.concat(remoteUsers);
|
||||
}
|
||||
|
||||
if (users.length < limit) {
|
||||
const remoteUsers = await User
|
||||
.find({
|
||||
host: null,
|
||||
usernameLower: new RegExp(escapeRegexp(query.toLowerCase()))
|
||||
}, {
|
||||
limit: limit - users.length
|
||||
});
|
||||
|
||||
users = users.concat(remoteUsers);
|
||||
}
|
||||
|
||||
if (users.length < limit) {
|
||||
const remoteUsers = await User
|
||||
.find({
|
||||
|
Loading…
Reference in New Issue
Block a user