             .get() (err, res, body) =>
               data = JSON.parse(body)
               msg.send "#{@name}: #{data.issues.length + ((total_pages - 1) * 25)}"
+
+  get_milestone_issues: (msg) ->
+    milestone_url = "#{@api_url}/milestones/"
+    msg.http("#{milestone_url}")
+    .header('X-Sifter-Token', token)
+    .header('Accept', 'application/json')
+    .header('User-Agent', 'Active Faith Hubot')
+    .get() (err, res, body) =>
+      data = JSON.parse(body)
+      unless data.milestones.length is 0
+        for milestone in data.milestones
+          do(milestone) =>
+            milestone_issue_url = milestone.api_issues_url
+            msg.http("#{milestone_issue_url}&s=1-2-3}")
+            .header('X-Sifter-Token', token)
+            .header('Accept', 'application/json')
+            .header('User-Agent', 'Active Faith Hubot')
+            .get() (err, res, body) =>
+              data = JSON.parse(body)
+              total_pages = data.total_pages
+              unless data.issues.length is 0
+                msg.send "#{@name} > #{milestone.name}: #{data.issues.length}"


  robot.respond /(give me a )*(milestone report)+/i, (msg) ->
    msg.send "--Open issues per milestone--"


class Project 
  constructor: (project, msg) ->
    @name = project.name
    @api_issues_url = project.api_issues_url + "?s=1-2-3"

  get_total_issues: (msg) ->
    msg.http("#{@api_issues_url}")

#
#
#
token = process.env.HUBOT_SIFTER_TOKEN
company = process.env.HUBOT_SIFTER_COMPANY
module.exports = (robot) ->
  robot.respond /(give me a )*(sift(e|a)r report)+/i, (msg)->
    msg.send "--Open issues per project--"
