diff --git a/src/services/chart/charts/classes/instance.ts b/src/services/chart/charts/classes/instance.ts index 974eac036b..55db534573 100644 --- a/src/services/chart/charts/classes/instance.ts +++ b/src/services/chart/charts/classes/instance.ts @@ -4,6 +4,7 @@ import { SchemaType } from '../../../../misc/schema'; import { DriveFiles, Followings, Users, Notes } from '../../../../models'; import { DriveFile } from '../../../../models/entities/drive-file'; import { name, schema } from '../schemas/instance'; +import { Note } from '../../../../models/entities/note'; type InstanceLog = SchemaType; @@ -107,12 +108,23 @@ export default class InstanceChart extends Chart { } @autobind - public async updateNote(host: string, isAdditional: boolean) { + public async updateNote(host: string, note: Note, isAdditional: boolean) { + const diffs = {} as any; + + if (note.replyId != null) { + diffs.reply = isAdditional ? 1 : -1; + } else if (note.renoteId != null) { + diffs.renote = isAdditional ? 1 : -1; + } else { + diffs.normal = isAdditional ? 1 : -1; + } + await this.inc({ notes: { total: isAdditional ? 1 : -1, inc: isAdditional ? 1 : 0, dec: isAdditional ? 0 : 1, + diffs: diffs } }, host); } diff --git a/src/services/chart/charts/schemas/instance.ts b/src/services/chart/charts/schemas/instance.ts index af46b33629..001f2428b5 100644 --- a/src/services/chart/charts/schemas/instance.ts +++ b/src/services/chart/charts/schemas/instance.ts @@ -21,6 +21,7 @@ export const schema = { }, } }, + notes: { type: 'object' as 'object', properties: { @@ -36,8 +37,29 @@ export const schema = { type: 'number' as 'number', description: '減少した投稿数' }, + + diffs: { + type: 'object' as 'object', + properties: { + normal: { + type: 'number' as 'number', + description: '通常の投稿数の差分' + }, + + reply: { + type: 'number' as 'number', + description: 'リプライの投稿数の差分' + }, + + renote: { + type: 'number' as 'number', + description: 'Renoteの投稿数の差分' + }, + } + }, } }, + users: { type: 'object' as 'object', properties: { @@ -55,6 +77,7 @@ export const schema = { }, } }, + following: { type: 'object' as 'object', properties: { @@ -72,6 +95,7 @@ export const schema = { }, } }, + followers: { type: 'object' as 'object', properties: { @@ -89,6 +113,7 @@ export const schema = { }, } }, + drive: { type: 'object' as 'object', properties: { diff --git a/src/services/note/create.ts b/src/services/note/create.ts index 305e173e16..05837a4daf 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -207,7 +207,7 @@ export default async (user: User, data: Option, silent = false) => new Promise { Instances.increment({ id: i.id }, 'notesCount', 1); - instanceChart.updateNote(i.host, true); + instanceChart.updateNote(i.host, note, true); }); } diff --git a/src/services/note/delete.ts b/src/services/note/delete.ts index 7f04d12cd5..c03c742ee1 100644 --- a/src/services/note/delete.ts +++ b/src/services/note/delete.ts @@ -56,7 +56,7 @@ export default async function(user: User, note: Note, quiet = false) { if (Users.isRemoteUser(user)) { registerOrFetchInstanceDoc(user.host).then(i => { Instances.decrement({ id: i.id }, 'notesCount', 1); - instanceChart.updateNote(i.host, false); + instanceChart.updateNote(i.host, note, false); }); } }