Skip to content
Snippets Groups Projects
Commit bef67fa2 authored by syuilo's avatar syuilo
Browse files

Update trend.ts

parent 05d71986
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@ import { Note } from '../../../../models/entities/note';
..が理想だけどPostgreSQLでどうするのか分からないので単に「直近Aの内に投稿されたユニーク投稿数が多いハッシュタグ」で妥協する
*/
const rangeA = 1000 * 60 * 30; // 30分
const rangeA = 1000 * 60 * 60; // 60分
//const rangeB = 1000 * 60 * 120; // 2時間
//const coefficient = 1.25; // 「n倍」の部分
//const requiredUsers = 3; // 最低何人がそのタグを投稿している必要があるか
......@@ -123,16 +123,16 @@ export default define(meta, async () => {
}
const countsLog = await Promise.all(countPromises);
//#endregion
const totalCounts = await Promise.all(hots.map(tag => Notes.createQueryBuilder('note')
.select('count(distinct note.userId)')
.where(':tag = ANY(note.tags)', { tag: tag })
.andWhere('note.createdAt > :gt', { gt: new Date(now.getTime() - (interval * range)) })
.cache(60000) // 1 min
.andWhere('note.createdAt > :gt', { gt: new Date(now.getTime() - rangeA) })
.cache(60000 * 60) // 60 min
.getRawOne()
.then(x => parseInt(x.count, 10))
));
//#endregion
const stats = hots.map((tag, i) => ({
tag,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment