Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save tcannonfodder/55c2a855f3dbbf61e65d to your computer and use it in GitHub Desktop.

Select an option

Save tcannonfodder/55c2a855f3dbbf61e65d to your computer and use it in GitHub Desktop.
entries = YourHTTPClientOfChoice.get("https://api.letsfreckle.com/v2/entries?project_ids=1234&from=2016-01-03&to=2016-01-09")
# a hash, where the key is the tag name and the value is
# the total number of minutes logged using this tag
# example {"email" => 90 }
tag_totals = {}
entries.each do |entry|
minutes = entry["minutes"]
# iterate through all the entries tags, adding the entry's minutes to the tag's total
entry.tags.each do |tag|
if !tag_totals.has_key?(tag["name"])
tag_totals[tag["name"]] = 0
end
tag_totals[tag["name"]] += minutes
end
end
# Now you have all the time totals by tag!
puts tag_totals.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment