diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-02-08 04:31:33 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-02-08 04:31:33 +0900 |
| commit | aba85b977dfc868c1a65ce06ed58ea59d0371f7f (patch) | |
| tree | 5e27a5397bb3ee93ae1790ed2f92c6264ae86956 /src/chart/federation.ts | |
| parent | Implement instance blocking (#4182) (diff) | |
| download | sharkey-aba85b977dfc868c1a65ce06ed58ea59d0371f7f.tar.gz sharkey-aba85b977dfc868c1a65ce06ed58ea59d0371f7f.tar.bz2 sharkey-aba85b977dfc868c1a65ce06ed58ea59d0371f7f.zip | |
Refactoring: Move chart dir into services dir
Diffstat (limited to 'src/chart/federation.ts')
| -rw-r--r-- | src/chart/federation.ts | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/src/chart/federation.ts b/src/chart/federation.ts deleted file mode 100644 index 5bb41f00a2..0000000000 --- a/src/chart/federation.ts +++ /dev/null @@ -1,66 +0,0 @@ -import autobind from 'autobind-decorator'; -import Chart, { Obj } from '.'; -import Instance from '../models/instance'; - -/** - * フェデレーションに関するチャート - */ -type FederationLog = { - instance: { - /** - * インスタンス数の合計 - */ - total: number; - - /** - * 増加インスタンス数 - */ - inc: number; - - /** - * 減少インスタンス数 - */ - dec: number; - }; -}; - -class FederationChart extends Chart<FederationLog> { - constructor() { - super('federation'); - } - - @autobind - protected async getTemplate(init: boolean, latest?: FederationLog): Promise<FederationLog> { - const [total] = init ? await Promise.all([ - Instance.count({}) - ]) : [ - latest ? latest.instance.total : 0 - ]; - - return { - instance: { - total: total, - inc: 0, - dec: 0 - } - }; - } - - @autobind - public async update(isAdditional: boolean) { - const update: Obj = {}; - - update.total = isAdditional ? 1 : -1; - if (isAdditional) { - update.inc = 1; - } else { - update.dec = 1; - } - - await this.inc({ - instance: update - }); - } -} - -export default new FederationChart(); |