Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
fix: fixed a efficiency calculator bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zxch3n committed Dec 10, 2019
1 parent 64e854c commit bfa7d67
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/efficiency/efficiency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ export function getEfficiency(isDistractionArr: boolean[], stayTimeArr: number[]
0
);

if (totalTime === focusedTime || (isDistractionArr.length === 1 && !isDistractionArr[0])) {
return 1;
}

let prevEfficiency = 0;
for (let i = 0; i < stayTimeArr.length; i += 1) {
if (isDistractionArr[i]) {
continue;
}

let lossFactor = 1;
if (prevEfficiency !== 0) {
if (i > 0) {
lossFactor = 1 - Math.sqrt(Math.min(stayTimeArr[i - 1] / 30, 1)) * 0.5 - 0.5;
}

Expand Down

0 comments on commit bfa7d67

Please sign in to comment.