1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-01-31 06:18:07 +00:00

refactor: 実行プロセスを修正

This commit is contained in:
kohei 2018-11-19 18:46:47 +09:00
parent 9bea9c2e25
commit 0508d129c7

View file

@ -1,24 +1,20 @@
export default ({ activity }) => { export default ({ activity }) => {
const leftActivity = activity const leftActivity = activity.filter(a => a.ch === "l"),
.filter(a => a.ch === "l") rightActivity = activity.filter(a => a.ch === "r");
.map(a => a.endTime - a.startTime) const [l, r] = [leftActivity, rightActivity].map(activity => {
.reduce((a, c) => a + c, 0); return activity
const rightActivity = activity
.filter(a => a.ch === "r")
.map(a => a.endTime - a.startTime) .map(a => a.endTime - a.startTime)
.reduce((a, c) => a + c, 0); .reduce((a, c) => a + c, 0);
});
const sum = l + r;
return ( return (
<dl> <dl>
<dt>会話時間 (ms)</dt> <dt>会話時間 (ms)</dt>
<dd>{leftActivity + rightActivity}</dd> <dd>{sum}</dd>
<dt>会話の割合</dt> <dt>会話の割合</dt>
<dd> <dd>
{" "} <meter value={l / sum}>{l / sum}</meter>
<meter value={leftActivity / (leftActivity + rightActivity)}>
{leftActivity / (leftActivity + rightActivity)}
</meter>{" "}
</dd> </dd>
</dl> </dl>
); );