Files
misskey/src/services/chart/charts/classes/test.ts
syuilo 96b2267cb8 Chart resyncing (#5372)
* wip

* Add test

* Fix test

* Insert moderation log

* Add todo
2019-09-02 04:41:26 +09:00

46 lines
844 B
TypeScript

import autobind from 'autobind-decorator';
import Chart, { Obj, DeepPartial } from '../../core';
import { SchemaType } from '../../../../misc/schema';
import { name, schema } from '../schemas/test';
type TestLog = SchemaType<typeof schema>;
export default class TestChart extends Chart<TestLog> {
public total = 0; // publicにするのはテストのため
constructor() {
super(name, schema);
}
@autobind
protected genNewLog(latest: TestLog): DeepPartial<TestLog> {
return {
foo: {
total: latest.foo.total,
},
};
}
@autobind
protected async fetchActual(): Promise<DeepPartial<TestLog>> {
return {
foo: {
total: this.total,
},
};
}
@autobind
public async increment() {
const update: Obj = {};
update.total = 1;
update.inc = 1;
this.total++;
await this.inc({
foo: update
});
}
}