diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-06-12 02:00:05 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-06-12 02:00:05 +0900 |
| commit | ebde84214e57eb5a3af9f28a6671710d78232bfd (patch) | |
| tree | 404ac5f032e8ee5891a295c451ded7f7c8847f3e /src/server/api/endpoints | |
| parent | 変数調整 (diff) | |
| download | sharkey-ebde84214e57eb5a3af9f28a6671710d78232bfd.tar.gz sharkey-ebde84214e57eb5a3af9f28a6671710d78232bfd.tar.bz2 sharkey-ebde84214e57eb5a3af9f28a6671710d78232bfd.zip | |
Improve hashtag trend detection
Diffstat (limited to 'src/server/api/endpoints')
| -rw-r--r-- | src/server/api/endpoints/hashtags/trend.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/server/api/endpoints/hashtags/trend.ts b/src/server/api/endpoints/hashtags/trend.ts index 43048c1c9f..efd74a21e0 100644 --- a/src/server/api/endpoints/hashtags/trend.ts +++ b/src/server/api/endpoints/hashtags/trend.ts @@ -8,6 +8,7 @@ import Note from '../../../../models/note'; const rangeA = 1000 * 60 * 30; // 30分 const rangeB = 1000 * 60 * 120; // 2時間 const coefficient = 1.5; // 「n倍」の部分 +const requiredUsers = 3; // 最低何人がそのタグを投稿している必要があるか /** * Get trends of hashtags @@ -42,7 +43,7 @@ module.exports = () => new Promise(async (res, rej) => { return res([]); } - const tags = []; + let tags = []; // カウント data.map(x => x._id).forEach(x => { @@ -57,6 +58,9 @@ module.exports = () => new Promise(async (res, rej) => { } }); + // 最低要求投稿者数を下回るならカットする + tags = tags.filter(tag => tag.count >= requiredUsers); + //#region 2. 1で取得したそれぞれのタグについて、「直近a分間のユニーク投稿数が今からa分前~今からb分前の間のユニーク投稿数のn倍以上」かどうかを判定する const hotsPromises = tags.map(async tag => { const passedCount = (await Note.distinct('userId', { |