Skip to content

Instantly share code, notes, and snippets.

@haifeng
Created June 28, 2013 19:25
Show Gist options
  • Save haifeng/5887361 to your computer and use it in GitHub Desktop.
Save haifeng/5887361 to your computer and use it in GitHub Desktop.
for maciek
(14..28).each do |day|
(0..23).each do |hour|
key = "201306#{day}:#{hour}:510ac2293d3d9dda100001eb:app-hourly-events"
hash = R.hgetall(key)
nav_count = 0
ui_count = 0
hash.each do |k, v|
nav_count += v.to_i if k.index("page:navigate:")
ui_count += v.to_i if k.index("ui:article-open:")
end
result << {date: "6/#{day}/2013 #{hour}:00:00", nav: nav_count, ui: ui_count}
end
end
file = File.open("/home/staging/1.csv", "w")
result.each do |r|
file.write("#{r[:date]}, #{r[:nav]}, #{r[:ui]}\r\n")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment