Improve instance chart
This commit is contained in:
		@@ -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<typeof schema>;
 | 
			
		||||
 | 
			
		||||
@@ -107,12 +108,23 @@ export default class InstanceChart extends Chart<InstanceLog> {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@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);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -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: {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user