Created
June 16, 2015 23:08
-
-
Save esshka/d1fefb666d9e78bfa203 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
den = Math.ceil(rawdata.length / 500); | |
processedData = _(rawdata) | |
.chunk(den) | |
.map(function(part){ | |
if (!part) return | |
if (part.length === 0) { | |
return; | |
} | |
else { | |
let average = (+new Date(_.last(part).time) - +new Date(_.first(part).time)) / (den*1000); | |
let type = 'norm'; | |
if (average >= normalCycleMin && average <= normalCycleMax) { | |
type = 'norm'; | |
} else if (average < normalCycleMin) { | |
type = 'acl'; | |
} else if (average > normalCycleMax * 5 && average > 1000 * 60 * 5) { | |
type = 'idle'; | |
} else if (average > normalCycleMax) { | |
type = 'fail'; | |
} else { | |
type = 'fail'; | |
} | |
return { | |
type: type, | |
ts: +new Date(_.first(part).time) | |
}; | |
} | |
}) | |
.compact() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment