diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2019-02-08 16:58:57 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-08 16:58:57 +0900 |
| commit | 56275bcfcbd1366b0e96b79915e810baed0548bb (patch) | |
| tree | b35c8a6bd15ef8046c00119f0271808970f4f939 /src/server/api/endpoints | |
| parent | Supress logs during test (diff) | |
| download | sharkey-56275bcfcbd1366b0e96b79915e810baed0548bb.tar.gz sharkey-56275bcfcbd1366b0e96b79915e810baed0548bb.tar.bz2 sharkey-56275bcfcbd1366b0e96b79915e810baed0548bb.zip | |
Introduce per-instance chart (#4183)
* Introduce per-instance chart
* Implement chart view in client
* Handle note deleting
* More chart srcs
* Add drive stats
* Improve drive stats
* Fix bug
* Add icon
Diffstat (limited to 'src/server/api/endpoints')
| -rw-r--r-- | src/server/api/endpoints/charts/instance.ts | 42 | ||||
| -rw-r--r-- | src/server/api/endpoints/federation/instances.ts | 16 |
2 files changed, 58 insertions, 0 deletions
diff --git a/src/server/api/endpoints/charts/instance.ts b/src/server/api/endpoints/charts/instance.ts new file mode 100644 index 0000000000..99e7d9c1e1 --- /dev/null +++ b/src/server/api/endpoints/charts/instance.ts @@ -0,0 +1,42 @@ +import $ from 'cafy'; +import define from '../../define'; +import instanceChart from '../../../../services/chart/instance'; + +export const meta = { + stability: 'stable', + + desc: { + 'ja-JP': 'インスタンスごとのチャートを取得します。' + }, + + params: { + span: { + validator: $.str.or(['day', 'hour']), + desc: { + 'ja-JP': '集計のスパン (day または hour)' + } + }, + + limit: { + validator: $.num.optional.range(1, 500), + default: 30, + desc: { + 'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。' + } + }, + + host: { + validator: $.str, + desc: { + 'ja-JP': '対象のインスタンスのホスト', + 'en-US': 'Target instance host' + } + } + } +}; + +export default define(meta, (ps) => new Promise(async (res, rej) => { + const stats = await instanceChart.getChart(ps.span as any, ps.limit, ps.host); + + res(stats); +})); diff --git a/src/server/api/endpoints/federation/instances.ts b/src/server/api/endpoints/federation/instances.ts index ce0d10af28..9b4efbaaff 100644 --- a/src/server/api/endpoints/federation/instances.ts +++ b/src/server/api/endpoints/federation/instances.ts @@ -70,6 +70,22 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => { sort = { caughtAt: 1 }; + } else if (ps.sort == '+driveUsage') { + sort = { + driveUsage: -1 + }; + } else if (ps.sort == '-driveUsage') { + sort = { + driveUsage: 1 + }; + } else if (ps.sort == '+driveFiles') { + sort = { + driveFiles: -1 + }; + } else if (ps.sort == '-driveFiles') { + sort = { + driveFiles: 1 + }; } } else { sort = { |