Improve doc

This commit is contained in:
syuilo 2019-02-24 12:23:31 +09:00
parent d994c84901
commit 5db7b2e193
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
2 changed files with 42 additions and 27 deletions

View file

@ -1,6 +1,7 @@
import $ from 'cafy'; import $ from 'cafy';
import define from '../../define'; import define from '../../define';
import usersChart from '../../../../services/chart/users'; import usersChart, { usersLogSchema } from '../../../../services/chart/users';
import { convertLog } from '../../../../services/chart';
export const meta = { export const meta = {
stability: 'stable', stability: 'stable',
@ -28,12 +29,7 @@ export const meta = {
}, },
}, },
res: { res: convertLog(usersLogSchema),
type: 'array',
items: {
type: 'object',
},
},
}; };
export default define(meta, async (ps) => { export default define(meta, async (ps) => {

View file

@ -1,31 +1,50 @@
import autobind from 'autobind-decorator'; import autobind from 'autobind-decorator';
import Chart, { Obj } from './'; import Chart, { Obj } from './';
import User, { IUser, isLocalUser } from '../../models/user'; import User, { IUser, isLocalUser } from '../../models/user';
import { SchemaType } from '../../prelude/schema';
/** const logSchema = {
*
*/
type UsersLog = {
local: {
/** /**
* *
*/ */
total: number; total: {
type: 'number' as 'number',
description: '集計期間時点での、全ユーザー数'
},
/** /**
* *
*/ */
inc: number; inc: {
type: 'number' as 'number',
description: '増加したユーザー数'
},
/** /**
* *
*/ */
dec: number; dec: {
type: 'number' as 'number',
description: '減少したユーザー数'
},
}; };
remote: UsersLog['local']; export const usersLogSchema = {
type: 'object' as 'object',
properties: {
local: {
type: 'object' as 'object',
properties: logSchema
},
remote: {
type: 'object' as 'object',
properties: logSchema
},
}
}; };
type UsersLog = SchemaType<typeof usersLogSchema>;
class UsersChart extends Chart<UsersLog> { class UsersChart extends Chart<UsersLog> {
constructor() { constructor() {
super('users'); super('users');