summaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2019-02-17 23:41:47 +0900
committerGitHub <noreply@github.com>2019-02-17 23:41:47 +0900
commit1d5a54ff6f74569fa89c4083301d9b01eb80ad29 (patch)
tree0695f8ee6942b49236b880bb228be45b26282e90 /src/models
parentFix #4300 (#4304) (diff)
downloadmisskey-1d5a54ff6f74569fa89c4083301d9b01eb80ad29.tar.gz
misskey-1d5a54ff6f74569fa89c4083301d9b01eb80ad29.tar.bz2
misskey-1d5a54ff6f74569fa89c4083301d9b01eb80ad29.zip
ハッシュタグでユーザー検索できるように (#4298)
* ハッシュタグでユーザー検索できるように * :art: * Increase limit * リモートユーザーも表示 * Fix bug * Fix bug * Improve performance
Diffstat (limited to 'src/models')
-rw-r--r--src/models/hashtag.ts34
-rw-r--r--src/models/user.ts1
2 files changed, 33 insertions, 2 deletions
diff --git a/src/models/hashtag.ts b/src/models/hashtag.ts
index f5b6156055..742e4a254c 100644
--- a/src/models/hashtag.ts
+++ b/src/models/hashtag.ts
@@ -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;
}
diff --git a/src/models/user.ts b/src/models/user.ts
index 6cc44f371d..2549b2568a 100644
--- a/src/models/user.ts
+++ b/src/models/user.ts
@@ -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');