This commit is contained in:
syuilo 2019-03-15 13:51:23 +09:00
parent 40f8654e47
commit 4fcc912614
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
}); });