Sharkey/packages/backend/src/services/chart/charts/test.ts
syuilo c1b264e4e9
Improve chart engine (#8253)
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update core.ts

* wip

* wip

* #7361

* delete network chart

* federationChart強化 apRequestChart追加

* tweak
2022-02-06 00:13:52 +09:00

42 lines
791 B
TypeScript

import autobind from 'autobind-decorator';
import Chart, { KVs } from '../core';
import { name, schema } from './entities/test';
/**
* For testing
*/
// eslint-disable-next-line import/no-default-export
export default class TestChart extends Chart<typeof schema> {
public total = 0; // publicにするのはテストのため
constructor() {
super(name, schema);
}
@autobind
protected async queryCurrentState(): Promise<Partial<KVs<typeof schema>>> {
return {
'foo.total': this.total,
};
}
@autobind
public async increment(): Promise<void> {
this.total++;
await this.commit({
'foo.total': 1,
'foo.inc': 1,
});
}
@autobind
public async decrement(): Promise<void> {
this.total--;
await this.commit({
'foo.total': -1,
'foo.dec': 1,
});
}
}