ハッシュタグでユーザー検索できるように (#4298)

* ハッシュタグでユーザー検索できるように

* 🎨

* Increase limit

* リモートユーザーも表示

* Fix bug

* Fix bug

* Improve performance
This commit is contained in:
syuilo
2019-02-17 23:41:47 +09:00
committed by GitHub
parent 03e2c7eec6
commit 1d5a54ff6f
22 changed files with 366 additions and 56 deletions

View File

@ -3,11 +3,41 @@ import db from '../db/mongodb';
const Hashtag = db.get<IHashtags>('hashtags');
Hashtag.createIndex('tag', { unique: true });
Hashtag.createIndex('mentionedUserIdsCount');
Hashtag.createIndex('mentionedUsersCount');
Hashtag.createIndex('mentionedLocalUsersCount');
Hashtag.createIndex('attachedUsersCount');
Hashtag.createIndex('attachedLocalUsersCount');
export default Hashtag;
// 後方互換性のため
Hashtag.findOne({ attachedUserIds: { $exists: false }}).then(h => {
if (h != null) {
Hashtag.update({}, {
$rename: {
mentionedUserIdsCount: 'mentionedUsersCount'
},
$set: {
mentionedLocalUserIds: [],
mentionedLocalUsersCount: 0,
attachedUserIds: [],
attachedUsersCount: 0,
attachedLocalUserIds: [],
attachedLocalUsersCount: 0,
}
}, {
multi: true
});
}
});
export interface IHashtags {
tag: string;
mentionedUserIds: mongo.ObjectID[];
mentionedUserIdsCount: number;
mentionedUsersCount: number;
mentionedLocalUserIds: mongo.ObjectID[];
mentionedLocalUsersCount: number;
attachedUserIds: mongo.ObjectID[];
attachedUsersCount: number;
attachedLocalUserIds: mongo.ObjectID[];
attachedLocalUsersCount: number;
}

View File

@ -18,6 +18,7 @@ const User = db.get<IUser>('users');
User.createIndex('createdAt');
User.createIndex('updatedAt');
User.createIndex('followersCount');
User.createIndex('tags');
User.createIndex('username');
User.createIndex('usernameLower');
User.createIndex('host');