Created
April 5, 2015 04:34
-
-
Save trengrj/af8ebdee3e759cf5818b 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
var moment = require('moment'); | |
var data = require('./one-week.json'); | |
var t = {}; | |
data.forEach(function(d) { | |
var segments = d.segments; | |
segments.forEach(function(s) { | |
var activities = s.activities; | |
activities.forEach(function(a) { | |
if (a.activity == "wlk") { | |
var timeStamp = moment.utc(a.startTime.replace(/[0-9]{4}Z/,''),"YYYYMMDDTHH").unix().toString(); | |
if (a.steps) { | |
t[timeStamp] = (t[timeStamp]) ? t[timeStamp] + a.steps : a.steps; | |
} | |
} | |
}); | |
}); | |
}); | |
console.log(JSON.stringify(t)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment