summaryrefslogtreecommitdiff
path: root/src/server/index.ts
diff options
context:
space:
mode:
authorAya Morisawa <AyaMorisawa4869@gmail.com>2018-11-09 11:02:23 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2018-11-09 11:02:23 +0900
commit276edd7cc2ca38bf4d3e5f47add2ff993e7a7364 (patch)
tree8b1b8ec2866e45af95ec84aabdab999ba256f302 /src/server/index.ts
parentFix #3170 (#3173) (diff)
downloadsharkey-276edd7cc2ca38bf4d3e5f47add2ff993e7a7364.tar.gz
sharkey-276edd7cc2ca38bf4d3e5f47add2ff993e7a7364.tar.bz2
sharkey-276edd7cc2ca38bf4d3e5f47add2ff993e7a7364.zip
Use sum function (#3174)
Diffstat (limited to 'src/server/index.ts')
-rw-r--r--src/server/index.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/server/index.ts b/src/server/index.ts
index f1933dc405..77c869bb4e 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -19,6 +19,7 @@ import webFinger from './webfinger';
import config from '../config';
import networkChart from '../chart/network';
import apiServer from './api';
+import { sum } from '../prelude/array';
// Init app
const app = new Koa();
@@ -99,9 +100,9 @@ export default () => new Promise(resolve => {
if (queue.length == 0) return;
const requests = queue.length;
- const time = queue.reduce((a, b) => a + b.time, 0);
- const incomingBytes = queue.reduce((a, b) => a + b.req.bytes, 0);
- const outgoingBytes = queue.reduce((a, b) => a + b.res.bytes, 0);
+ const time = sum(queue.map(x => x.time));
+ const incomingBytes = sum(queue.map(x => x.req.byets));
+ const outgoingBytes = sum(queue.map(x => x.res.byets));
queue = [];
networkChart.update(requests, time, incomingBytes, outgoingBytes);