refactor: Use ESM (#8358)
* wip * wip * fix * clean up * Update tsconfig.json * Update activitypub.ts * wip
This commit is contained in:
@ -1,8 +1,7 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { User } from '@/models/entities/user';
|
||||
import { Users } from '@/models/index';
|
||||
import { name, schema } from './entities/active-users';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { User } from '@/models/entities/user.js';
|
||||
import { Users } from '@/models/index.js';
|
||||
import { name, schema } from './entities/active-users.js';
|
||||
|
||||
const week = 1000 * 60 * 60 * 24 * 7;
|
||||
const month = 1000 * 60 * 60 * 24 * 30;
|
||||
@ -17,17 +16,14 @@ export default class ActiveUsersChart extends Chart<typeof schema> {
|
||||
super(name, schema);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async read(user: { id: User['id'], host: null, createdAt: User['createdAt'] }): Promise<void> {
|
||||
await this.commit({
|
||||
'read': [user.id],
|
||||
@ -40,7 +36,6 @@ export default class ActiveUsersChart extends Chart<typeof schema> {
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async write(user: { id: User['id'], host: null, createdAt: User['createdAt'] }): Promise<void> {
|
||||
await this.commit({
|
||||
'write': [user.id],
|
||||
|
@ -1,6 +1,5 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { name, schema } from './entities/ap-request';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { name, schema } from './entities/ap-request.js';
|
||||
|
||||
/**
|
||||
* Chart about ActivityPub requests
|
||||
@ -11,31 +10,26 @@ export default class ApRequestChart extends Chart<typeof schema> {
|
||||
super(name, schema);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async deliverSucc(): Promise<void> {
|
||||
await this.commit({
|
||||
'deliverSucceeded': 1,
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async deliverFail(): Promise<void> {
|
||||
await this.commit({
|
||||
'deliverFailed': 1,
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async inbox(): Promise<void> {
|
||||
await this.commit({
|
||||
'inboxReceived': 1,
|
||||
|
@ -1,9 +1,8 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { DriveFiles } from '@/models/index';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { DriveFiles } from '@/models/index.js';
|
||||
import { Not, IsNull } from 'typeorm';
|
||||
import { DriveFile } from '@/models/entities/drive-file';
|
||||
import { name, schema } from './entities/drive';
|
||||
import { DriveFile } from '@/models/entities/drive-file.js';
|
||||
import { name, schema } from './entities/drive.js';
|
||||
|
||||
/**
|
||||
* ドライブに関するチャート
|
||||
@ -14,17 +13,14 @@ export default class DriveChart extends Chart<typeof schema> {
|
||||
super(name, schema);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(file: DriveFile, isAdditional: boolean): Promise<void> {
|
||||
const fileSizeKb = file.size / 1000;
|
||||
await this.commit(file.userHost === null ? {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'activeUsers';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'apRequest';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'drive';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'federation';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'hashtag';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'instance';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'notes';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'perUserDrive';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'perUserFollowing';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'perUserNotes';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'perUserReaction';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'testGrouped';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'testIntersection';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'testUnique';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'test';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Chart from '../../core';
|
||||
import Chart from '../../core.js';
|
||||
|
||||
export const name = 'users';
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { Followings } from '@/models/index';
|
||||
import { name, schema } from './entities/federation';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { Followings } from '@/models/index.js';
|
||||
import { name, schema } from './entities/federation.js';
|
||||
|
||||
/**
|
||||
* フェデレーションに関するチャート
|
||||
@ -12,13 +11,11 @@ export default class FederationChart extends Chart<typeof schema> {
|
||||
super(name, schema);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {
|
||||
};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
const pubsubSubQuery = Followings.createQueryBuilder('f')
|
||||
.select('f.followerHost')
|
||||
@ -51,7 +48,6 @@ export default class FederationChart extends Chart<typeof schema> {
|
||||
};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async deliverd(host: string, succeeded: boolean): Promise<void> {
|
||||
await this.commit(succeeded ? {
|
||||
'deliveredInstances': [host],
|
||||
@ -60,7 +56,6 @@ export default class FederationChart extends Chart<typeof schema> {
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async inbox(host: string): Promise<void> {
|
||||
await this.commit({
|
||||
'inboxInstances': [host],
|
||||
|
@ -1,8 +1,7 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { User } from '@/models/entities/user';
|
||||
import { Users } from '@/models/index';
|
||||
import { name, schema } from './entities/hashtag';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { User } from '@/models/entities/user.js';
|
||||
import { Users } from '@/models/index.js';
|
||||
import { name, schema } from './entities/hashtag.js';
|
||||
|
||||
/**
|
||||
* ハッシュタグに関するチャート
|
||||
@ -13,17 +12,14 @@ export default class HashtagChart extends Chart<typeof schema> {
|
||||
super(name, schema, true);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(hashtag: string, user: { id: User['id'], host: User['host'] }): Promise<void> {
|
||||
await this.commit({
|
||||
'local.users': Users.isLocalUser(user) ? [user.id] : [],
|
||||
|
@ -1,10 +1,9 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { DriveFiles, Followings, Users, Notes } from '@/models/index';
|
||||
import { DriveFile } from '@/models/entities/drive-file';
|
||||
import { Note } from '@/models/entities/note';
|
||||
import { toPuny } from '@/misc/convert-host';
|
||||
import { name, schema } from './entities/instance';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { DriveFiles, Followings, Users, Notes } from '@/models/index.js';
|
||||
import { DriveFile } from '@/models/entities/drive-file.js';
|
||||
import { Note } from '@/models/entities/note.js';
|
||||
import { toPuny } from '@/misc/convert-host.js';
|
||||
import { name, schema } from './entities/instance.js';
|
||||
|
||||
/**
|
||||
* インスタンスごとのチャート
|
||||
@ -15,7 +14,6 @@ export default class InstanceChart extends Chart<typeof schema> {
|
||||
super(name, schema, true);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(group: string): Promise<Partial<KVs<typeof schema>>> {
|
||||
const [
|
||||
notesCount,
|
||||
@ -42,19 +40,16 @@ export default class InstanceChart extends Chart<typeof schema> {
|
||||
};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async requestReceived(host: string): Promise<void> {
|
||||
await this.commit({
|
||||
'requests.received': 1,
|
||||
}, toPuny(host));
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async requestSent(host: string, isSucceeded: boolean): Promise<void> {
|
||||
await this.commit({
|
||||
'requests.succeeded': isSucceeded ? 1 : 0,
|
||||
@ -62,7 +57,6 @@ export default class InstanceChart extends Chart<typeof schema> {
|
||||
}, toPuny(host));
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async newUser(host: string): Promise<void> {
|
||||
await this.commit({
|
||||
'users.total': 1,
|
||||
@ -70,7 +64,6 @@ export default class InstanceChart extends Chart<typeof schema> {
|
||||
}, toPuny(host));
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async updateNote(host: string, note: Note, isAdditional: boolean): Promise<void> {
|
||||
await this.commit({
|
||||
'notes.total': isAdditional ? 1 : -1,
|
||||
@ -83,7 +76,6 @@ export default class InstanceChart extends Chart<typeof schema> {
|
||||
}, toPuny(host));
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async updateFollowing(host: string, isAdditional: boolean): Promise<void> {
|
||||
await this.commit({
|
||||
'following.total': isAdditional ? 1 : -1,
|
||||
@ -92,7 +84,6 @@ export default class InstanceChart extends Chart<typeof schema> {
|
||||
}, toPuny(host));
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async updateFollowers(host: string, isAdditional: boolean): Promise<void> {
|
||||
await this.commit({
|
||||
'followers.total': isAdditional ? 1 : -1,
|
||||
@ -101,7 +92,6 @@ export default class InstanceChart extends Chart<typeof schema> {
|
||||
}, toPuny(host));
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async updateDrive(file: DriveFile, isAdditional: boolean): Promise<void> {
|
||||
const fileSizeKb = file.size / 1000;
|
||||
await this.commit({
|
||||
|
@ -1,9 +1,8 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { Notes } from '@/models/index';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { Notes } from '@/models/index.js';
|
||||
import { Not, IsNull } from 'typeorm';
|
||||
import { Note } from '@/models/entities/note';
|
||||
import { name, schema } from './entities/notes';
|
||||
import { Note } from '@/models/entities/note.js';
|
||||
import { name, schema } from './entities/notes.js';
|
||||
|
||||
/**
|
||||
* ノートに関するチャート
|
||||
@ -14,7 +13,6 @@ export default class NotesChart extends Chart<typeof schema> {
|
||||
super(name, schema);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
const [localCount, remoteCount] = await Promise.all([
|
||||
Notes.count({ userHost: null }),
|
||||
@ -27,12 +25,10 @@ export default class NotesChart extends Chart<typeof schema> {
|
||||
};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(note: Note, isAdditional: boolean): Promise<void> {
|
||||
const prefix = note.userHost === null ? 'local' : 'remote';
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { DriveFiles } from '@/models/index';
|
||||
import { DriveFile } from '@/models/entities/drive-file';
|
||||
import { name, schema } from './entities/per-user-drive';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { DriveFiles } from '@/models/index.js';
|
||||
import { DriveFile } from '@/models/entities/drive-file.js';
|
||||
import { name, schema } from './entities/per-user-drive.js';
|
||||
|
||||
/**
|
||||
* ユーザーごとのドライブに関するチャート
|
||||
@ -13,7 +12,6 @@ export default class PerUserDriveChart extends Chart<typeof schema> {
|
||||
super(name, schema, true);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(group: string): Promise<Partial<KVs<typeof schema>>> {
|
||||
const [count, size] = await Promise.all([
|
||||
DriveFiles.count({ userId: group }),
|
||||
@ -26,12 +24,10 @@ export default class PerUserDriveChart extends Chart<typeof schema> {
|
||||
};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(file: DriveFile, isAdditional: boolean): Promise<void> {
|
||||
const fileSizeKb = file.size / 1000;
|
||||
await this.commit({
|
||||
|
@ -1,9 +1,8 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { Followings, Users } from '@/models/index';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { Followings, Users } from '@/models/index.js';
|
||||
import { Not, IsNull } from 'typeorm';
|
||||
import { User } from '@/models/entities/user';
|
||||
import { name, schema } from './entities/per-user-following';
|
||||
import { User } from '@/models/entities/user.js';
|
||||
import { name, schema } from './entities/per-user-following.js';
|
||||
|
||||
/**
|
||||
* ユーザーごとのフォローに関するチャート
|
||||
@ -14,7 +13,6 @@ export default class PerUserFollowingChart extends Chart<typeof schema> {
|
||||
super(name, schema, true);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(group: string): Promise<Partial<KVs<typeof schema>>> {
|
||||
const [
|
||||
localFollowingsCount,
|
||||
@ -36,12 +34,10 @@ export default class PerUserFollowingChart extends Chart<typeof schema> {
|
||||
};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(follower: { id: User['id']; host: User['host']; }, followee: { id: User['id']; host: User['host']; }, isFollow: boolean): Promise<void> {
|
||||
const prefixFollower = Users.isLocalUser(follower) ? 'local' : 'remote';
|
||||
const prefixFollowee = Users.isLocalUser(followee) ? 'local' : 'remote';
|
||||
|
@ -1,9 +1,8 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { User } from '@/models/entities/user';
|
||||
import { Notes } from '@/models/index';
|
||||
import { Note } from '@/models/entities/note';
|
||||
import { name, schema } from './entities/per-user-notes';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { User } from '@/models/entities/user.js';
|
||||
import { Notes } from '@/models/index.js';
|
||||
import { Note } from '@/models/entities/note.js';
|
||||
import { name, schema } from './entities/per-user-notes.js';
|
||||
|
||||
/**
|
||||
* ユーザーごとのノートに関するチャート
|
||||
@ -14,7 +13,6 @@ export default class PerUserNotesChart extends Chart<typeof schema> {
|
||||
super(name, schema, true);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(group: string): Promise<Partial<KVs<typeof schema>>> {
|
||||
const [count] = await Promise.all([
|
||||
Notes.count({ userId: group }),
|
||||
@ -25,12 +23,10 @@ export default class PerUserNotesChart extends Chart<typeof schema> {
|
||||
};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(user: { id: User['id'] }, note: Note, isAdditional: boolean): Promise<void> {
|
||||
await this.commit({
|
||||
'total': isAdditional ? 1 : -1,
|
||||
|
@ -1,9 +1,8 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { User } from '@/models/entities/user';
|
||||
import { Note } from '@/models/entities/note';
|
||||
import { Users } from '@/models/index';
|
||||
import { name, schema } from './entities/per-user-reactions';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { User } from '@/models/entities/user.js';
|
||||
import { Note } from '@/models/entities/note.js';
|
||||
import { Users } from '@/models/index.js';
|
||||
import { name, schema } from './entities/per-user-reactions.js';
|
||||
|
||||
/**
|
||||
* ユーザーごとのリアクションに関するチャート
|
||||
@ -14,17 +13,14 @@ export default class PerUserReactionsChart extends Chart<typeof schema> {
|
||||
super(name, schema, true);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(group: string): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(user: { id: User['id'], host: User['host'] }, note: Note): Promise<void> {
|
||||
const prefix = Users.isLocalUser(user) ? 'local' : 'remote';
|
||||
this.commit({
|
||||
|
@ -1,6 +1,5 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { name, schema } from './entities/test-grouped';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { name, schema } from './entities/test-grouped.js';
|
||||
|
||||
/**
|
||||
* For testing
|
||||
@ -13,19 +12,16 @@ export default class TestGroupedChart extends Chart<typeof schema> {
|
||||
super(name, schema, true);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(group: string): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {
|
||||
'foo.total': this.total[group],
|
||||
};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async increment(group: string): Promise<void> {
|
||||
if (this.total[group] == null) this.total[group] = 0;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { name, schema } from './entities/test-intersection';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { name, schema } from './entities/test-intersection.js';
|
||||
|
||||
/**
|
||||
* For testing
|
||||
@ -11,24 +10,20 @@ export default class TestIntersectionChart extends Chart<typeof schema> {
|
||||
super(name, schema);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async addA(key: string): Promise<void> {
|
||||
await this.commit({
|
||||
a: [key],
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async addB(key: string): Promise<void> {
|
||||
await this.commit({
|
||||
b: [key],
|
||||
|
@ -1,6 +1,5 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { name, schema } from './entities/test-unique';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { name, schema } from './entities/test-unique.js';
|
||||
|
||||
/**
|
||||
* For testing
|
||||
@ -11,17 +10,14 @@ export default class TestUniqueChart extends Chart<typeof schema> {
|
||||
super(name, schema);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async uniqueIncrement(key: string): Promise<void> {
|
||||
await this.commit({
|
||||
foo: [key],
|
||||
|
@ -1,6 +1,5 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { name, schema } from './entities/test';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { name, schema } from './entities/test.js';
|
||||
|
||||
/**
|
||||
* For testing
|
||||
@ -13,19 +12,16 @@ export default class TestChart extends Chart<typeof schema> {
|
||||
super(name, schema);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {
|
||||
'foo.total': this.total,
|
||||
};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async increment(): Promise<void> {
|
||||
this.total++;
|
||||
|
||||
@ -35,7 +31,6 @@ export default class TestChart extends Chart<typeof schema> {
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async decrement(): Promise<void> {
|
||||
this.total--;
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
import autobind from 'autobind-decorator';
|
||||
import Chart, { KVs } from '../core';
|
||||
import { Users } from '@/models/index';
|
||||
import Chart, { KVs } from '../core.js';
|
||||
import { Users } from '@/models/index.js';
|
||||
import { Not, IsNull } from 'typeorm';
|
||||
import { User } from '@/models/entities/user';
|
||||
import { name, schema } from './entities/users';
|
||||
import { User } from '@/models/entities/user.js';
|
||||
import { name, schema } from './entities/users.js';
|
||||
|
||||
/**
|
||||
* ユーザー数に関するチャート
|
||||
@ -14,7 +13,6 @@ export default class UsersChart extends Chart<typeof schema> {
|
||||
super(name, schema);
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
const [localCount, remoteCount] = await Promise.all([
|
||||
Users.count({ host: null }),
|
||||
@ -27,12 +25,10 @@ export default class UsersChart extends Chart<typeof schema> {
|
||||
};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public async update(user: { id: User['id'], host: User['host'] }, isAdditional: boolean): Promise<void> {
|
||||
const prefix = Users.isLocalUser(user) ? 'local' : 'remote';
|
||||
|
||||
|
Reference in New Issue
Block a user