This commit is contained in:
syuilo 2019-03-15 13:51:23 +09:00
parent 5a87763193
commit dfabdef60f
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
2 changed files with 5 additions and 2 deletions

View File

@ -20,6 +20,7 @@ User.createIndex('createdAt');
User.createIndex('updatedAt'); User.createIndex('updatedAt');
User.createIndex('followersCount'); User.createIndex('followersCount');
User.createIndex('tags'); User.createIndex('tags');
User.createIndex('isSuspended');
User.createIndex('username'); User.createIndex('username');
User.createIndex('usernameLower'); User.createIndex('usernameLower');
User.createIndex('host'); User.createIndex('host');

View File

@ -70,7 +70,8 @@ export default define(meta, async (ps, me) => {
users = await User users = await User
.find({ .find({
host: null, host: null,
usernameLower: new RegExp('^' + escapeRegexp(ps.query.replace('@', '').toLowerCase())) usernameLower: new RegExp('^' + escapeRegexp(ps.query.replace('@', '').toLowerCase())),
isSuspended: false
}, { }, {
limit: ps.limit, limit: ps.limit,
skip: ps.offset skip: ps.offset
@ -80,7 +81,8 @@ export default define(meta, async (ps, me) => {
const otherUsers = await User const otherUsers = await User
.find({ .find({
host: { $ne: null }, host: { $ne: null },
usernameLower: new RegExp('^' + escapeRegexp(ps.query.replace('@', '').toLowerCase())) usernameLower: new RegExp('^' + escapeRegexp(ps.query.replace('@', '').toLowerCase())),
isSuspended: false
}, { }, {
limit: ps.limit - users.length limit: ps.limit - users.length
}); });