From f9f2ca51acc02c838d9592bc2c7ef8590ab07468 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 3 Nov 2018 11:37:44 +0900 Subject: [PATCH] Improve stats API --- src/server/api/endpoints/stats.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/server/api/endpoints/stats.ts b/src/server/api/endpoints/stats.ts index 56549848d..2f0a8b466 100644 --- a/src/server/api/endpoints/stats.ts +++ b/src/server/api/endpoints/stats.ts @@ -1,5 +1,7 @@ import Meta from '../../../models/meta'; import define from '../define'; +import driveChart from '../../../chart/drive'; +import federationChart from '../../../chart/federation'; export const meta = { requireCredential: false, @@ -15,5 +17,16 @@ export const meta = { export default define(meta, () => new Promise(async (res, rej) => { const meta = await Meta.findOne(); - res(meta ? meta.stats : {}); + 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]; + + console.log(driveStats); + + const federationStats = await federationChart.getChart('hour', 1); + stats.instances = federationStats.instance.total[0]; + + res(stats); }));