analyse moves data with jq, ruby, plotly

i wanted to play a little with the data my fitness tracker moves collect. albeit the privacy issues moves (now owned by facebook) saves alle the movement data on their servers.
usually i bike to work. the distance is around 11,5km. is wanted to analyse the trips from home to work and back. if there is a specific weekday where i am faster or where i drive more often. what i did:

get you moves data here.

using jq to filter moves json data like this:

$ echo "[" >l
$ jq '.[].segments|.[] | select(.type=="move") | .activities | .[] | select(.activity=="cycling")' *.json|sed 's/}/},/g'>>l
$ echo "{}]" >>l
$ mv l cycling.json

analyse this with some ruby. unfortunately moves sometimes detecs a bit rough what activity you are doing. so i didnt get continous blocks of the same activity for all rides. i tried to filter some of the rides by time and duration. heres the code:

require("json")  
require("awesome_print")  
require("time")

data = JSON.parse(IO.read("cycling.json"))  
Activity = Struct.new(:startTime, :endTime, :duration, :distance, :whichway)  
all_activities = Array.new  
data.each do |a|  
  act = Activity.new
  act.startTime = Time.parse(a["startTime"])
  act.endTime   = Time.parse(a["endTime"])
  act.duration  = a["duration"]/60
  act.distance  = a["distance"]
#  puts "#{act.startTime} - #{act.endTime}: #{act.duration}m, #{act.distance}"
  if !act.startTime.sunday? && !act.startTime.saturday?
    h = act.startTime.hour
    if act.duration > 15
      if (h > 6 && h < 9)
        act.whichway = "work"
        all_activities << act
      end
      if (h > 15 && h < 19)
        act.whichway = "home"
        all_activities << act
      end
    end
  end
end

puts "when:where, how many, min, max, avg"  
by_weekday = all_activities.group_by{|a| a.startTime.strftime("%a")}  
by_weekday.each do |wday, activities_outer|  
  activities_outer.group_by{|a| a.whichway}.each do |way, activities|
    durs = activities.map{|a|a.duration}
    dmin, dmax = durs.minmax
    davg = durs.inject(:+).to_f / activities.count
    vals = durs.join(",")
    puts "#{wday.rjust(2)}=>#{way}, #{activities.count.to_s.rjust(2)}, #{dmin.to_s.rjust(2)}, #{dmax.to_s.rjust(2)}, #{davg.to_i.to_s.rjust(2)}"
    #ap activities
  end
end

result as text:

when:where, how many, min, max, avg  
Mon=>home, 15, 18, 31, 24  
Mon=>work, 10, 16, 39, 29  
Tue=>work, 16, 19, 39, 30  
Tue=>home, 11, 16, 29, 25  
Wed=>work,  7, 17, 45, 31  
Wed=>home,  8, 21, 30, 25  
Thu=>work, 12, 19, 39, 30  
Thu=>home, 14, 22, 30, 25  
Fri=>work,  6, 25, 33, 30  
Fri=>home,  3, 27, 28, 27  

result as graph: