Implement #2980
This commit is contained in:
parent
e9a8090d7e
commit
3bebf82501
3 changed files with 87 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import watch from '../watch';
|
|||
import renderLike from '../../../remote/activitypub/renderer/like';
|
||||
import { deliver } from '../../../queue';
|
||||
import pack from '../../../remote/activitypub/renderer';
|
||||
import { perUserReactionsStats } from '../../stats';
|
||||
|
||||
export default async (user: IUser, note: INote, reaction: string) => new Promise(async (res, rej) => {
|
||||
// Myself
|
||||
|
|
@ -43,6 +44,8 @@ export default async (user: IUser, note: INote, reaction: string) => new Promise
|
|||
$inc: inc
|
||||
});
|
||||
|
||||
perUserReactionsStats.update(user, note);
|
||||
|
||||
publishNoteStream(note._id, 'reacted', {
|
||||
reaction: reaction,
|
||||
userId: user._id
|
||||
|
|
|
|||
|
|
@ -912,6 +912,49 @@ class PerUserNotesStats extends Stats<PerUserNotesLog> {
|
|||
export const perUserNotesStats = new PerUserNotesStats();
|
||||
//#endregion
|
||||
|
||||
//#region Per user reactions stats
|
||||
/**
|
||||
* ユーザーごとのリアクションに関する統計
|
||||
*/
|
||||
type PerUserReactionsLog = {
|
||||
local: {
|
||||
/**
|
||||
* リアクションされた数
|
||||
*/
|
||||
count: number;
|
||||
};
|
||||
|
||||
remote: PerUserReactionsLog['local'];
|
||||
};
|
||||
|
||||
class PerUserReactionsStats extends Stats<PerUserReactionsLog> {
|
||||
constructor() {
|
||||
super('perUserReaction', true);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async getTemplate(init: boolean, latest?: PerUserReactionsLog, group?: any): Promise<PerUserReactionsLog> {
|
||||
return {
|
||||
local: {
|
||||
count: 0
|
||||
},
|
||||
remote: {
|
||||
count: 0
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(user: IUser, note: INote) {
|
||||
this.inc({
|
||||
[isLocalUser(user) ? 'local' : 'remote']: { count: 1 }
|
||||
}, note.userId);
|
||||
}
|
||||
}
|
||||
|
||||
export const perUserReactionsStats = new PerUserReactionsStats();
|
||||
//#endregion
|
||||
|
||||
//#region Per user drive stats
|
||||
/**
|
||||
* ユーザーごとのドライブに関する統計
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue