enhance(backend): improve chart engine
This commit is contained in:
@ -1,12 +1,16 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { Obj, DeepPartial } from '../../core';
|
||||
import Chart, { Obj, DeepPartial } from '../core';
|
||||
import { User } from '@/models/entities/user';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { Users } from '@/models/index';
|
||||
import { name, schema } from '../schemas/active-users';
|
||||
import { name, schema } from './entities/active-users';
|
||||
|
||||
type ActiveUsersLog = SchemaType<typeof schema>;
|
||||
|
||||
/**
|
||||
* アクティブユーザーに関するチャート
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class ActiveUsersChart extends Chart<ActiveUsersLog> {
|
||||
constructor() {
|
||||
super(name, schema);
|
||||
@ -35,7 +39,7 @@ export default class ActiveUsersChart extends Chart<ActiveUsersLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(user: { id: User['id'], host: User['host'] }) {
|
||||
public async update(user: { id: User['id'], host: User['host'] }): Promise<void> {
|
||||
const update: Obj = {
|
||||
users: [user.id],
|
||||
};
|
@ -1,13 +1,17 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { Obj, DeepPartial } from '../../core';
|
||||
import Chart, { Obj, DeepPartial } from '../core';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { DriveFiles } from '@/models/index';
|
||||
import { Not, IsNull } from 'typeorm';
|
||||
import { DriveFile } from '@/models/entities/drive-file';
|
||||
import { name, schema } from '../schemas/drive';
|
||||
import { name, schema } from './entities/drive';
|
||||
|
||||
type DriveLog = SchemaType<typeof schema>;
|
||||
|
||||
/**
|
||||
* ドライブに関するチャート
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class DriveChart extends Chart<DriveLog> {
|
||||
constructor() {
|
||||
super(name, schema);
|
||||
@ -71,7 +75,7 @@ export default class DriveChart extends Chart<DriveLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(file: DriveFile, isAdditional: boolean) {
|
||||
public async update(file: DriveFile, isAdditional: boolean): Promise<void> {
|
||||
const update: Obj = {};
|
||||
|
||||
update.totalCount = isAdditional ? 1 : -1;
|
@ -1,4 +1,8 @@
|
||||
export const logSchema = {
|
||||
import Chart from '../../core';
|
||||
|
||||
export const name = 'activeUsers';
|
||||
|
||||
const logSchema = {
|
||||
/**
|
||||
* アクティブユーザー
|
||||
*/
|
||||
@ -12,9 +16,6 @@ export const logSchema = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* アクティブユーザーに関するチャート
|
||||
*/
|
||||
export const schema = {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
@ -32,4 +33,4 @@ export const schema = {
|
||||
},
|
||||
};
|
||||
|
||||
export const name = 'activeUsers';
|
||||
export const entity = Chart.schemaToEntity(name, schema);
|
@ -1,3 +1,7 @@
|
||||
import Chart from '../../core';
|
||||
|
||||
export const name = 'drive';
|
||||
|
||||
const logSchema = {
|
||||
/**
|
||||
* 集計期間時点での、全ドライブファイル数
|
||||
@ -65,4 +69,4 @@ export const schema = {
|
||||
},
|
||||
};
|
||||
|
||||
export const name = 'drive';
|
||||
export const entity = Chart.schemaToEntity(name, schema);
|
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* フェデレーションに関するチャート
|
||||
*/
|
||||
import Chart from '../../core';
|
||||
|
||||
export const name = 'federation';
|
||||
|
||||
export const schema = {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
@ -26,4 +27,4 @@ export const schema = {
|
||||
},
|
||||
};
|
||||
|
||||
export const name = 'federation';
|
||||
export const entity = Chart.schemaToEntity(name, schema);
|
@ -1,4 +1,8 @@
|
||||
export const logSchema = {
|
||||
import Chart from '../../core';
|
||||
|
||||
export const name = 'hashtag';
|
||||
|
||||
const logSchema = {
|
||||
/**
|
||||
* 投稿したユーザー
|
||||
*/
|
||||
@ -12,9 +16,6 @@ export const logSchema = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* ハッシュタグに関するチャート
|
||||
*/
|
||||
export const schema = {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
@ -32,4 +33,4 @@ export const schema = {
|
||||
},
|
||||
};
|
||||
|
||||
export const name = 'hashtag';
|
||||
export const entity = Chart.schemaToEntity(name, schema, true);
|
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* インスタンスごとのチャート
|
||||
*/
|
||||
import Chart from '../../core';
|
||||
|
||||
export const name = 'instance';
|
||||
|
||||
export const schema = {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
@ -154,4 +155,4 @@ export const schema = {
|
||||
},
|
||||
};
|
||||
|
||||
export const name = 'instance';
|
||||
export const entity = Chart.schemaToEntity(name, schema, true);
|
@ -1,6 +1,7 @@
|
||||
/**
|
||||
* ネットワークに関するチャート
|
||||
*/
|
||||
import Chart from '../../core';
|
||||
|
||||
export const name = 'network';
|
||||
|
||||
export const schema = {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
@ -28,4 +29,4 @@ export const schema = {
|
||||
},
|
||||
};
|
||||
|
||||
export const name = 'network';
|
||||
export const entity = Chart.schemaToEntity(name, schema);
|
@ -1,3 +1,7 @@
|
||||
import Chart from '../../core';
|
||||
|
||||
export const name = 'notes';
|
||||
|
||||
const logSchema = {
|
||||
total: {
|
||||
type: 'number' as const,
|
||||
@ -53,4 +57,4 @@ export const schema = {
|
||||
},
|
||||
};
|
||||
|
||||
export const name = 'notes';
|
||||
export const entity = Chart.schemaToEntity(name, schema);
|
@ -1,3 +1,7 @@
|
||||
import Chart from '../../core';
|
||||
|
||||
export const name = 'perUserDrive';
|
||||
|
||||
export const schema = {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
@ -52,4 +56,4 @@ export const schema = {
|
||||
},
|
||||
};
|
||||
|
||||
export const name = 'perUserDrive';
|
||||
export const entity = Chart.schemaToEntity(name, schema, true);
|
@ -1,4 +1,8 @@
|
||||
export const logSchema = {
|
||||
import Chart from '../../core';
|
||||
|
||||
export const name = 'perUserFollowing';
|
||||
|
||||
const logSchema = {
|
||||
/**
|
||||
* フォローしている
|
||||
*/
|
||||
@ -83,4 +87,4 @@ export const schema = {
|
||||
},
|
||||
};
|
||||
|
||||
export const name = 'perUserFollowing';
|
||||
export const entity = Chart.schemaToEntity(name, schema, true);
|
@ -1,3 +1,7 @@
|
||||
import Chart from '../../core';
|
||||
|
||||
export const name = 'perUserNotes';
|
||||
|
||||
export const schema = {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
@ -40,4 +44,4 @@ export const schema = {
|
||||
},
|
||||
};
|
||||
|
||||
export const name = 'perUserNotes';
|
||||
export const entity = Chart.schemaToEntity(name, schema, true);
|
@ -1,6 +1,10 @@
|
||||
export const logSchema = {
|
||||
import Chart from '../../core';
|
||||
|
||||
export const name = 'perUserReaction';
|
||||
|
||||
const logSchema = {
|
||||
/**
|
||||
* フォローしている合計
|
||||
* 被リアクション数
|
||||
*/
|
||||
count: {
|
||||
type: 'number' as const,
|
||||
@ -8,9 +12,6 @@ export const logSchema = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* ユーザーごとのリアクションに関するチャート
|
||||
*/
|
||||
export const schema = {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
@ -28,4 +29,4 @@ export const schema = {
|
||||
},
|
||||
};
|
||||
|
||||
export const name = 'perUserReaction';
|
||||
export const entity = Chart.schemaToEntity(name, schema, true);
|
@ -1,3 +1,7 @@
|
||||
import Chart from '../../core';
|
||||
|
||||
export const name = 'testGrouped';
|
||||
|
||||
export const schema = {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
@ -25,4 +29,4 @@ export const schema = {
|
||||
},
|
||||
};
|
||||
|
||||
export const name = 'testGrouped';
|
||||
export const entity = Chart.schemaToEntity(name, schema, true);
|
@ -1,3 +1,7 @@
|
||||
import Chart from '../../core';
|
||||
|
||||
export const name = 'testUnique';
|
||||
|
||||
export const schema = {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
@ -13,4 +17,4 @@ export const schema = {
|
||||
},
|
||||
};
|
||||
|
||||
export const name = 'testUnique';
|
||||
export const entity = Chart.schemaToEntity(name, schema);
|
@ -1,3 +1,7 @@
|
||||
import Chart from '../../core';
|
||||
|
||||
export const name = 'test';
|
||||
|
||||
export const schema = {
|
||||
type: 'object' as const,
|
||||
optional: false as const, nullable: false as const,
|
||||
@ -25,4 +29,4 @@ export const schema = {
|
||||
},
|
||||
};
|
||||
|
||||
export const name = 'test';
|
||||
export const entity = Chart.schemaToEntity(name, schema);
|
@ -1,3 +1,7 @@
|
||||
import Chart from '../../core';
|
||||
|
||||
export const name = 'users';
|
||||
|
||||
const logSchema = {
|
||||
/**
|
||||
* 集計期間時点での、全ユーザー数
|
||||
@ -41,4 +45,4 @@ export const schema = {
|
||||
},
|
||||
};
|
||||
|
||||
export const name = 'users';
|
||||
export const entity = Chart.schemaToEntity(name, schema);
|
@ -1,11 +1,15 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { Obj, DeepPartial } from '../../core';
|
||||
import Chart, { Obj, DeepPartial } from '../core';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { Instances } from '@/models/index';
|
||||
import { name, schema } from '../schemas/federation';
|
||||
import { name, schema } from './entities/federation';
|
||||
|
||||
type FederationLog = SchemaType<typeof schema>;
|
||||
|
||||
/**
|
||||
* フェデレーションに関するチャート
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class FederationChart extends Chart<FederationLog> {
|
||||
constructor() {
|
||||
super(name, schema);
|
||||
@ -45,7 +49,7 @@ export default class FederationChart extends Chart<FederationLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(isAdditional: boolean) {
|
||||
public async update(isAdditional: boolean): Promise<void> {
|
||||
const update: Obj = {};
|
||||
|
||||
update.total = isAdditional ? 1 : -1;
|
@ -1,12 +1,16 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { Obj, DeepPartial } from '../../core';
|
||||
import Chart, { Obj, DeepPartial } from '../core';
|
||||
import { User } from '@/models/entities/user';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { Users } from '@/models/index';
|
||||
import { name, schema } from '../schemas/hashtag';
|
||||
import { name, schema } from './entities/hashtag';
|
||||
|
||||
type HashtagLog = SchemaType<typeof schema>;
|
||||
|
||||
/**
|
||||
* ハッシュタグに関するチャート
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class HashtagChart extends Chart<HashtagLog> {
|
||||
constructor() {
|
||||
super(name, schema, true);
|
||||
@ -35,7 +39,7 @@ export default class HashtagChart extends Chart<HashtagLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(hashtag: string, user: { id: User['id'], host: User['host'] }) {
|
||||
public async update(hashtag: string, user: { id: User['id'], host: User['host'] }): Promise<void> {
|
||||
const update: Obj = {
|
||||
users: [user.id],
|
||||
};
|
@ -1,17 +1,21 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { Obj, DeepPartial } from '../../core';
|
||||
import Chart, { Obj, DeepPartial } from '../core';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { DriveFiles, Followings, Users, Notes } from '@/models/index';
|
||||
import { DriveFile } from '@/models/entities/drive-file';
|
||||
import { name, schema } from '../schemas/instance';
|
||||
import { Note } from '@/models/entities/note';
|
||||
import { toPuny } from '@/misc/convert-host';
|
||||
import { name, schema } from './entities/instance';
|
||||
|
||||
type InstanceLog = SchemaType<typeof schema>;
|
||||
|
||||
/**
|
||||
* インスタンスごとのチャート
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class InstanceChart extends Chart<InstanceLog> {
|
||||
constructor() {
|
||||
super(name, schema);
|
||||
super(name, schema, true);
|
||||
}
|
||||
|
||||
@autobind
|
||||
@ -119,7 +123,7 @@ export default class InstanceChart extends Chart<InstanceLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async requestReceived(host: string) {
|
||||
public async requestReceived(host: string): Promise<void> {
|
||||
await this.inc({
|
||||
requests: {
|
||||
received: 1,
|
||||
@ -128,7 +132,7 @@ export default class InstanceChart extends Chart<InstanceLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async requestSent(host: string, isSucceeded: boolean) {
|
||||
public async requestSent(host: string, isSucceeded: boolean): Promise<void> {
|
||||
const update: Obj = {};
|
||||
|
||||
if (isSucceeded) {
|
||||
@ -143,7 +147,7 @@ export default class InstanceChart extends Chart<InstanceLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async newUser(host: string) {
|
||||
public async newUser(host: string): Promise<void> {
|
||||
await this.inc({
|
||||
users: {
|
||||
total: 1,
|
||||
@ -153,8 +157,8 @@ export default class InstanceChart extends Chart<InstanceLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async updateNote(host: string, note: Note, isAdditional: boolean) {
|
||||
const diffs = {} as any;
|
||||
public async updateNote(host: string, note: Note, isAdditional: boolean): Promise<void> {
|
||||
const diffs = {} as Record<string, unknown>;
|
||||
|
||||
if (note.replyId != null) {
|
||||
diffs.reply = isAdditional ? 1 : -1;
|
||||
@ -175,7 +179,7 @@ export default class InstanceChart extends Chart<InstanceLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async updateFollowing(host: string, isAdditional: boolean) {
|
||||
public async updateFollowing(host: string, isAdditional: boolean): Promise<void> {
|
||||
await this.inc({
|
||||
following: {
|
||||
total: isAdditional ? 1 : -1,
|
||||
@ -186,7 +190,7 @@ export default class InstanceChart extends Chart<InstanceLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async updateFollowers(host: string, isAdditional: boolean) {
|
||||
public async updateFollowers(host: string, isAdditional: boolean): Promise<void> {
|
||||
await this.inc({
|
||||
followers: {
|
||||
total: isAdditional ? 1 : -1,
|
||||
@ -197,7 +201,7 @@ export default class InstanceChart extends Chart<InstanceLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async updateDrive(file: DriveFile, isAdditional: boolean) {
|
||||
public async updateDrive(file: DriveFile, isAdditional: boolean): Promise<void> {
|
||||
const update: Obj = {};
|
||||
|
||||
update.totalFiles = isAdditional ? 1 : -1;
|
@ -1,10 +1,14 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { DeepPartial } from '../../core';
|
||||
import Chart, { DeepPartial } from '../core';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { name, schema } from '../schemas/network';
|
||||
import { name, schema } from './entities/network';
|
||||
|
||||
type NetworkLog = SchemaType<typeof schema>;
|
||||
|
||||
/**
|
||||
* ネットワークに関するチャート
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class NetworkChart extends Chart<NetworkLog> {
|
||||
constructor() {
|
||||
super(name, schema);
|
||||
@ -32,7 +36,7 @@ export default class NetworkChart extends Chart<NetworkLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(incomingRequests: number, time: number, incomingBytes: number, outgoingBytes: number) {
|
||||
public async update(incomingRequests: number, time: number, incomingBytes: number, outgoingBytes: number): Promise<void> {
|
||||
const inc: DeepPartial<NetworkLog> = {
|
||||
incomingRequests: incomingRequests,
|
||||
totalTime: time,
|
@ -1,13 +1,17 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { Obj, DeepPartial } from '../../core';
|
||||
import Chart, { Obj, DeepPartial } from '../core';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { Notes } from '@/models/index';
|
||||
import { Not, IsNull } from 'typeorm';
|
||||
import { Note } from '@/models/entities/note';
|
||||
import { name, schema } from '../schemas/notes';
|
||||
import { name, schema } from './entities/notes';
|
||||
|
||||
type NotesLog = SchemaType<typeof schema>;
|
||||
|
||||
/**
|
||||
* ノートに関するチャート
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class NotesChart extends Chart<NotesLog> {
|
||||
constructor() {
|
||||
super(name, schema);
|
||||
@ -69,7 +73,7 @@ export default class NotesChart extends Chart<NotesLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(note: Note, isAdditional: boolean) {
|
||||
public async update(note: Note, isAdditional: boolean): Promise<void> {
|
||||
const update: Obj = {
|
||||
diffs: {},
|
||||
};
|
@ -1,12 +1,16 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { Obj, DeepPartial } from '../../core';
|
||||
import Chart, { Obj, DeepPartial } from '../core';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { DriveFiles } from '@/models/index';
|
||||
import { DriveFile } from '@/models/entities/drive-file';
|
||||
import { name, schema } from '../schemas/per-user-drive';
|
||||
import { name, schema } from './entities/per-user-drive';
|
||||
|
||||
type PerUserDriveLog = SchemaType<typeof schema>;
|
||||
|
||||
/**
|
||||
* ユーザーごとのドライブに関するチャート
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class PerUserDriveChart extends Chart<PerUserDriveLog> {
|
||||
constructor() {
|
||||
super(name, schema, true);
|
||||
@ -46,7 +50,7 @@ export default class PerUserDriveChart extends Chart<PerUserDriveLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(file: DriveFile, isAdditional: boolean) {
|
||||
public async update(file: DriveFile, isAdditional: boolean): Promise<void> {
|
||||
const update: Obj = {};
|
||||
|
||||
update.totalCount = isAdditional ? 1 : -1;
|
@ -1,13 +1,17 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { Obj, DeepPartial } from '../../core';
|
||||
import Chart, { Obj, DeepPartial } from '../core';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { Followings, Users } from '@/models/index';
|
||||
import { Not, IsNull } from 'typeorm';
|
||||
import { User } from '@/models/entities/user';
|
||||
import { name, schema } from '../schemas/per-user-following';
|
||||
import { name, schema } from './entities/per-user-following';
|
||||
|
||||
type PerUserFollowingLog = SchemaType<typeof schema>;
|
||||
|
||||
/**
|
||||
* ユーザーごとのフォローに関するチャート
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class PerUserFollowingChart extends Chart<PerUserFollowingLog> {
|
||||
constructor() {
|
||||
super(name, schema, true);
|
||||
@ -100,7 +104,7 @@ export default class PerUserFollowingChart extends Chart<PerUserFollowingLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(follower: { id: User['id']; host: User['host']; }, followee: { id: User['id']; host: User['host']; }, isFollow: boolean) {
|
||||
public async update(follower: { id: User['id']; host: User['host']; }, followee: { id: User['id']; host: User['host']; }, isFollow: boolean): Promise<void> {
|
||||
const update: Obj = {};
|
||||
|
||||
update.total = isFollow ? 1 : -1;
|
@ -1,13 +1,17 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { Obj, DeepPartial } from '../../core';
|
||||
import Chart, { Obj, DeepPartial } from '../core';
|
||||
import { User } from '@/models/entities/user';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { Notes } from '@/models/index';
|
||||
import { Note } from '@/models/entities/note';
|
||||
import { name, schema } from '../schemas/per-user-notes';
|
||||
import { name, schema } from './entities/per-user-notes';
|
||||
|
||||
type PerUserNotesLog = SchemaType<typeof schema>;
|
||||
|
||||
/**
|
||||
* ユーザーごとのノートに関するチャート
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class PerUserNotesChart extends Chart<PerUserNotesLog> {
|
||||
constructor() {
|
||||
super(name, schema, true);
|
||||
@ -46,7 +50,7 @@ export default class PerUserNotesChart extends Chart<PerUserNotesLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(user: { id: User['id'] }, note: Note, isAdditional: boolean) {
|
||||
public async update(user: { id: User['id'] }, note: Note, isAdditional: boolean): Promise<void> {
|
||||
const update: Obj = {
|
||||
diffs: {},
|
||||
};
|
@ -1,13 +1,17 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { DeepPartial } from '../../core';
|
||||
import Chart, { DeepPartial } from '../core';
|
||||
import { User } from '@/models/entities/user';
|
||||
import { Note } from '@/models/entities/note';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { Users } from '@/models/index';
|
||||
import { name, schema } from '../schemas/per-user-reactions';
|
||||
import { name, schema } from './entities/per-user-reactions';
|
||||
|
||||
type PerUserReactionsLog = SchemaType<typeof schema>;
|
||||
|
||||
/**
|
||||
* ユーザーごとのリアクションに関するチャート
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class PerUserReactionsChart extends Chart<PerUserReactionsLog> {
|
||||
constructor() {
|
||||
super(name, schema, true);
|
||||
@ -36,7 +40,7 @@ export default class PerUserReactionsChart extends Chart<PerUserReactionsLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(user: { id: User['id'], host: User['host'] }, note: Note) {
|
||||
public async update(user: { id: User['id'], host: User['host'] }, note: Note): Promise<void> {
|
||||
this.inc({
|
||||
[Users.isLocalUser(user) ? 'local' : 'remote']: { count: 1 },
|
||||
}, note.userId);
|
@ -1,10 +1,14 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { Obj, DeepPartial } from '../../core';
|
||||
import Chart, { Obj, DeepPartial } from '../core';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { name, schema } from '../schemas/test-grouped';
|
||||
import { name, schema } from './entities/test-grouped';
|
||||
|
||||
type TestGroupedLog = SchemaType<typeof schema>;
|
||||
|
||||
/**
|
||||
* For testing
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class TestGroupedChart extends Chart<TestGroupedLog> {
|
||||
private total = {} as Record<string, number>;
|
||||
|
||||
@ -42,7 +46,7 @@ export default class TestGroupedChart extends Chart<TestGroupedLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async increment(group: string) {
|
||||
public async increment(group: string): Promise<void> {
|
||||
if (this.total[group] == null) this.total[group] = 0;
|
||||
|
||||
const update: Obj = {};
|
@ -1,10 +1,14 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { DeepPartial } from '../../core';
|
||||
import Chart, { DeepPartial } from '../core';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { name, schema } from '../schemas/test-unique';
|
||||
import { name, schema } from './entities/test-unique';
|
||||
|
||||
type TestUniqueLog = SchemaType<typeof schema>;
|
||||
|
||||
/**
|
||||
* For testing
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class TestUniqueChart extends Chart<TestUniqueLog> {
|
||||
constructor() {
|
||||
super(name, schema);
|
||||
@ -28,7 +32,7 @@ export default class TestUniqueChart extends Chart<TestUniqueLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async uniqueIncrement(key: string) {
|
||||
public async uniqueIncrement(key: string): Promise<void> {
|
||||
await this.inc({
|
||||
foo: [key],
|
||||
});
|
@ -1,10 +1,14 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { Obj, DeepPartial } from '../../core';
|
||||
import Chart, { Obj, DeepPartial } from '../core';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { name, schema } from '../schemas/test';
|
||||
import { name, schema } from './entities/test';
|
||||
|
||||
type TestLog = SchemaType<typeof schema>;
|
||||
|
||||
/**
|
||||
* For testing
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class TestChart extends Chart<TestLog> {
|
||||
public total = 0; // publicにするのはテストのため
|
||||
|
||||
@ -42,7 +46,7 @@ export default class TestChart extends Chart<TestLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async increment() {
|
||||
public async increment(): Promise<void> {
|
||||
const update: Obj = {};
|
||||
|
||||
update.total = 1;
|
||||
@ -55,7 +59,7 @@ export default class TestChart extends Chart<TestLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async decrement() {
|
||||
public async decrement(): Promise<void> {
|
||||
const update: Obj = {};
|
||||
|
||||
update.total = -1;
|
@ -1,13 +1,17 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { Obj, DeepPartial } from '../../core';
|
||||
import Chart, { Obj, DeepPartial } from '../core';
|
||||
import { SchemaType } from '@/misc/schema';
|
||||
import { Users } from '@/models/index';
|
||||
import { Not, IsNull } from 'typeorm';
|
||||
import { User } from '@/models/entities/user';
|
||||
import { name, schema } from '../schemas/users';
|
||||
import { name, schema } from './entities/users';
|
||||
|
||||
type UsersLog = SchemaType<typeof schema>;
|
||||
|
||||
/**
|
||||
* ユーザー数に関するチャート
|
||||
*/
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default class UsersChart extends Chart<UsersLog> {
|
||||
constructor() {
|
||||
super(name, schema);
|
||||
@ -59,7 +63,7 @@ export default class UsersChart extends Chart<UsersLog> {
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(user: { id: User['id'], host: User['host'] }, isAdditional: boolean) {
|
||||
public async update(user: { id: User['id'], host: User['host'] }, isAdditional: boolean): Promise<void> {
|
||||
const update: Obj = {};
|
||||
|
||||
update.total = isAdditional ? 1 : -1;
|
Reference in New Issue
Block a user