From 66098640ed3e118e01ab4d3cb32cf716897eb1da Mon Sep 17 00:00:00 2001 From: David McNett Date: Wed, 6 Feb 2013 00:01:00 -0600 Subject: [PATCH] Submit distance and heart_rate splits to RunKeeper when posting a new 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. --- packages/ergkeeper/runkeeper.tcl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/ergkeeper/runkeeper.tcl b/packages/ergkeeper/runkeeper.tcl index 890feb3..1256084 100644 --- a/packages/ergkeeper/runkeeper.tcl +++ b/packages/ergkeeper/runkeeper.tcl @@ -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) != ""} { @@ -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 "[$yo get]" + $yo delete + return + } lassign [runkeeper_json_post $::rkuser(fitness_activities) [$yo get]] success array_data details_data unset -nocomplain details headers