Skip to content

Instantly share code, notes, and snippets.

@esshka
Created June 16, 2015 23:08
Show Gist options
  • Save esshka/d1fefb666d9e78bfa203 to your computer and use it in GitHub Desktop.
Save esshka/d1fefb666d9e78bfa203 to your computer and use it in GitHub Desktop.
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