Skip to content

Commit

Permalink
Submit distance and heart_rate splits to RunKeeper when posting a new
Browse files Browse the repository at this point in the history
activity.  Sadly, RunKeeper does not support arbitrary distance splits,
so only the heart rate will show up on the RunKeeper site.

Hopefully they will address this deficiency in the API in a future
release.  This is the closest I can come to resolving issue #1 for now.
  • Loading branch information
nugget committed Feb 6, 2013
1 parent f453a0b commit 6609864
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/ergkeeper/runkeeper.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ proc runkeeper_json_post {method body} {
proc runkeeper_post_activity {id} {
set success 0
set details ""
set ::config(debug) 0

pg_select $::db "SELECT * FROM activities WHERE id = $id" buf {
if {$buf(posted) != ""} {
Expand All @@ -143,7 +144,29 @@ proc runkeeper_post_activity {id} {
$yo string $f number $buf($f)
}
$yo string gymEquipment string "Rowing Machine"

if {[info exists buf(splits)] && $buf(splits) ne ""} {
$yo string distance array_open
foreach split $buf(splits) {
array set s $split
$yo map_open string timestamp double $s(timestamp) string distance double $s(distance) map_close
}
$yo array_close
$yo string heart_rate array_open
foreach split $buf(splits) {
array set s $split
$yo map_open string timestamp double $s(timestamp) string heart_rate double $s(heart_rate) map_close
}
$yo array_close
}

$yo map_close

if {[opt_bool debug]} {
puts "<code>[$yo get]</code>"
$yo delete
return
}
lassign [runkeeper_json_post $::rkuser(fitness_activities) [$yo get]] success array_data details_data

unset -nocomplain details headers
Expand Down

0 comments on commit 6609864

Please sign in to comment.