Improve doc

This commit is contained in:
syuilo 2019-02-24 12:23:31 +09:00
parent 6528c53874
commit 73e84df9de
2 changed files with 42 additions and 27 deletions

View file

@ -1,6 +1,7 @@
import $ from 'cafy';
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 = {
stability: 'stable',
@ -28,12 +29,7 @@ export const meta = {
},
},
res: {
type: 'array',
items: {
type: 'object',
},
},
res: convertLog(usersLogSchema),
};
export default define(meta, async (ps) => {

View file

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