sharkey/src/server/api/endpoints/stats.ts

31 lines
768 B
TypeScript
Raw Normal View History

2018-06-16 10:40:53 +09:00
import Meta from '../../../models/meta';
2018-11-02 13:47:44 +09:00
import define from '../define';
2018-11-03 11:37:44 +09:00
import driveChart from '../../../chart/drive';
import federationChart from '../../../chart/federation';
2017-08-12 15:17:03 +09:00
2018-11-02 13:47:44 +09:00
export const meta = {
requireCredential: false,
desc: {
'en-US': 'Get the instance\'s statistics'
},
params: {
}
};
export default define(meta, () => new Promise(async (res, rej) => {
2018-06-16 10:40:53 +09:00
const meta = await Meta.findOne();
2017-08-12 15:17:03 +09:00
2018-11-03 11:37:44 +09:00
const stats: any = meta ? meta.stats : {};
const driveStats = await driveChart.getChart('hour', 1);
stats.driveUsageLocal = driveStats.local.totalSize[0];
stats.driveUsageRemote = driveStats.remote.totalSize[0];
const federationStats = await federationChart.getChart('hour', 1);
stats.instances = federationStats.instance.total[0];
res(stats);
2018-11-02 13:47:44 +09:00
}));