Skip to content

Instantly share code, notes, and snippets.

@anthonyringoet
Created August 12, 2019 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonyringoet/5c68aa6f1e35e5a6c8ac78113ce20725 to your computer and use it in GitHub Desktop.
Save anthonyringoet/5c68aa6f1e35e5a6c8ac78113ce20725 to your computer and use it in GitHub Desktop.
golden cheetah / road grand tours activity cleanup
// 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