From e9a8090d7eb5a6e62f5d59bac9057167af838e57 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 22 Oct 2018 17:13:06 +0900 Subject: [PATCH] Refactor --- src/services/following/create.ts | 4 ++-- src/services/following/delete.ts | 4 ++-- src/services/following/requests/accept.ts | 4 ++-- src/services/stats.ts | 14 +++++++------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/services/following/create.ts b/src/services/following/create.ts index 209c663a77..44c543885e 100644 --- a/src/services/following/create.ts +++ b/src/services/following/create.ts @@ -7,7 +7,7 @@ import renderFollow from '../../remote/activitypub/renderer/follow'; import renderAccept from '../../remote/activitypub/renderer/accept'; import { deliver } from '../../queue'; import createFollowRequest from './requests/create'; -import { followingStats } from '../stats'; +import { perUserFollowingStats } from '../stats'; export default async function(follower: IUser, followee: IUser, requestId?: string) { // フォロー対象が鍵アカウントである or @@ -53,7 +53,7 @@ export default async function(follower: IUser, followee: IUser, requestId?: stri }); //#endregion - followingStats.update(follower, followee, true); + perUserFollowingStats.update(follower, followee, true); // Publish follow event if (isLocalUser(follower)) { diff --git a/src/services/following/delete.ts b/src/services/following/delete.ts index 035e00ba32..da286ee987 100644 --- a/src/services/following/delete.ts +++ b/src/services/following/delete.ts @@ -5,7 +5,7 @@ import pack from '../../remote/activitypub/renderer'; import renderFollow from '../../remote/activitypub/renderer/follow'; import renderUndo from '../../remote/activitypub/renderer/undo'; import { deliver } from '../../queue'; -import { followingStats } from '../stats'; +import { perUserFollowingStats } from '../stats'; export default async function(follower: IUser, followee: IUser) { const following = await Following.findOne({ @@ -38,7 +38,7 @@ export default async function(follower: IUser, followee: IUser) { }); //#endregion - followingStats.update(follower, followee, false); + perUserFollowingStats.update(follower, followee, false); // Publish unfollow event if (isLocalUser(follower)) { diff --git a/src/services/following/requests/accept.ts b/src/services/following/requests/accept.ts index 9f02376a14..bccf632bf8 100644 --- a/src/services/following/requests/accept.ts +++ b/src/services/following/requests/accept.ts @@ -6,7 +6,7 @@ import renderAccept from '../../../remote/activitypub/renderer/accept'; import { deliver } from '../../../queue'; import Following from '../../../models/following'; import { publishMainStream } from '../../../stream'; -import { followingStats } from '../../stats'; +import { perUserFollowingStats } from '../../stats'; export default async function(followee: IUser, follower: IUser) { await Following.insert({ @@ -58,7 +58,7 @@ export default async function(followee: IUser, follower: IUser) { }); //#endregion - followingStats.update(follower, followee, true); + perUserFollowingStats.update(follower, followee, true); await User.update({ _id: followee._id }, { $inc: { diff --git a/src/services/stats.ts b/src/services/stats.ts index 558e1786d4..086420bb4b 100644 --- a/src/services/stats.ts +++ b/src/services/stats.ts @@ -694,11 +694,11 @@ class HashtagStats extends Stats { export const hashtagStats = new HashtagStats(); //#endregion -//#region Following stats +//#region Per user following stats /** * ユーザーごとのフォローに関する統計 */ -type FollowingLog = { +type PerUserFollowingLog = { local: { /** * フォローしている @@ -741,16 +741,16 @@ type FollowingLog = { }; }; - remote: FollowingLog['local']; + remote: PerUserFollowingLog['local']; }; -class FollowingStats extends Stats { +class PerUserFollowingStats extends Stats { constructor() { - super('following', true); + super('perUserFollowing', true); } @autobind - protected async getTemplate(init: boolean, latest?: FollowingLog, group?: any): Promise { + protected async getTemplate(init: boolean, latest?: PerUserFollowingLog, group?: any): Promise { const [ localFollowingsCount, localFollowersCount, @@ -817,7 +817,7 @@ class FollowingStats extends Stats { } } -export const followingStats = new FollowingStats(); +export const perUserFollowingStats = new PerUserFollowingStats(); //#endregion //#region Per user notes stats