Skip to content

Instantly share code, notes, and snippets.

@calebd
Created January 9, 2014 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calebd/8327122 to your computer and use it in GitHub Desktop.
Save calebd/8327122 to your computer and use it in GitHub Desktop.
HuBot script for checking the latest average iOS and Mac App Store review times.
# Description:
# Fetch iOS and Mac App Store average review times.
#
# Commands:
# bot review times
# bot review time
module.exports = (robot) ->
robot.respond /review times?/i, (msg) ->
msg.http("http://reviewtimes.shinydevelopment.com/sb_trend30.json")
.get() (error, response, body) ->
try
sequences = JSON.parse(body).graph.datasequences
ios = 0
osx = 0
sequences.forEach (sequence) ->
title = sequence.title
points = sequence.datapoints
value = points[points.length - 1].value
value = Math.round(value)
if title.match /ios/i
ios = value
else if title.match /mac/i
osx = value
msg.send "iOS: #{ios} days\nOS X: #{osx} days"
catch error
msg.send "Unable to get review times."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment