Compare commits

...

3 Commits

Author SHA1 Message Date
399eb60809 2.37.5 2018-06-12 02:47:17 +09:00
ed67e3506b ✌️ 2018-06-12 02:46:54 +09:00
d8ff37fc45 ✌️ 2018-06-12 02:28:28 +09:00
4 changed files with 25 additions and 9 deletions

View File

@ -258,6 +258,7 @@ common/views/widgets/posts-monitor.vue:
common/views/widgets/hashtags.vue:
title: "ハッシュタグ"
count: "{}人が投稿"
empty: "トレンドなし"
common/views/widgets/server.vue:
title: "サーバー情報"

View File

@ -1,8 +1,8 @@
{
"name": "misskey",
"author": "syuilo <i@syuilo.com>",
"version": "2.37.4",
"clientVersion": "1.0.6465",
"version": "2.37.5",
"clientVersion": "1.0.6468",
"codename": "nighthike",
"main": "./built/index.js",
"private": true,

View File

@ -5,6 +5,7 @@
<div class="mkw-hashtags--body" :data-mobile="platform == 'mobile'">
<p class="fetching" v-if="fetching">%fa:spinner .pulse .fw%%i18n:common.loading%<mk-ellipsis/></p>
<p class="empty" v-else-if="stats.length == 0">%fa:exclamation-circle%%i18n:@empty%</p>
<transition-group v-else tag="div" name="chart">
<div v-for="stat in stats" :key="stat.tag">
<div class="tag">
@ -65,6 +66,7 @@ export default define({
root(isDark)
.mkw-hashtags--body
> .fetching
> .empty
margin 0
padding 12px 16px
text-align center

View File

@ -10,6 +10,8 @@ const rangeB = 1000 * 60 * 120; // 2時間
const coefficient = 1.5; // 「n倍」の部分
const requiredUsers = 3; // 最低何人がそのタグを投稿している必要があるか
const max = 5;
/**
* Get trends of hashtags
*/
@ -43,7 +45,7 @@ module.exports = () => new Promise(async (res, rej) => {
return res([]);
}
let tags = [];
const tags = [];
// カウント
data.map(x => x._id).forEach(x => {
@ -59,10 +61,10 @@ module.exports = () => new Promise(async (res, rej) => {
});
// 最低要求投稿者数を下回るならカットする
tags = tags.filter(tag => tag.count >= requiredUsers);
const limitedTags = tags.filter(tag => tag.count >= requiredUsers);
//#region 2. 1で取得したそれぞれのタグについて、「直近a分間のユニーク投稿数が今からa分前今からb分前の間のユニーク投稿数のn倍以上」かどうかを判定する
const hotsPromises = tags.map(async tag => {
const hotsPromises = limitedTags.map(async tag => {
const passedCount = (await Note.distinct('userId', {
tags: tag.name,
createdAt: {
@ -71,7 +73,7 @@ module.exports = () => new Promise(async (res, rej) => {
}
}) as any).length;
if (tag.count > (passedCount * coefficient)) {
if (tag.count >= (passedCount * coefficient)) {
return tag;
} else {
return null;
@ -79,13 +81,24 @@ module.exports = () => new Promise(async (res, rej) => {
});
//#endregion
const hots = (await Promise.all(hotsPromises))
// タグを人気順に並べ替え
let hots = (await Promise.all(hotsPromises))
.filter(x => x != null)
.sort((a, b) => b.count - a.count)
.map(tag => tag.name)
.slice(0, 5);
.slice(0, max);
//#region 2で話題と判定されたタグそれぞれについて過去の投稿数グラフを取得す
//#region 3. もし上記の方法でのトレンド抽出の結果、求められているタグ数に達しなければ「ただ単に現在投稿数が多いハッシュタグ」に切り替え
if (hots.length < max) {
hots = hots.concat(tags
.filter(tag => hots.indexOf(tag.name) == -1)
.sort((a, b) => b.count - a.count)
.map(tag => tag.name)
.slice(0, max - hots.length));
}
//#endregion
//#region 2(または3)で話題と判定されたタグそれぞれについて過去の投稿数グラフを取得する
const countPromises: Array<Promise<any[]>> = [];
const range = 20;