Created
August 12, 2019 11:25
-
-
Save anthonyringoet/5c68aa6f1e35e5a6c8ac78113ce20725 to your computer and use it in GitHub Desktop.
golden cheetah / road grand tours activity cleanup
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
// Road grand tours imported activities in Golden Cheetah give issues if there are multiple entries per second. | |
// The detail view seems to be correct but it leads to incorrect max wattages in the trends overview. | |
const fs = require('fs'); | |
const { set, find, forEach } = require('lodash') | |
const activityData = require('./input.json') | |
const samples = activityData.RIDE.SAMPLES | |
let updatedSamples = [] | |
forEach(samples, record => { | |
const existingItemForSec = find(updatedSamples, { SECS: record.SECS }) | |
console.log({ SECS: record.SECS, existingItemForSec }) | |
if (existingItemForSec) return | |
updatedSamples.push(record) | |
}) | |
const output = set(activityData, 'RIDE.SAMPLES', updatedSamples) | |
fs.writeFileSync('./output.json', JSON.stringify(output)) | |
console.log('done\n-------') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment