diff --git a/README.md b/README.md index de0f6d3..ce77612 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ Usage envisaged in these three scenarios: ###Poll -An issue can be re-opened so we need to keep track of changes to individual tickets. Assume that polls happen quite frequently in the day and not say once a week or something. +Assuming it is quicker to get issue events and update existing data than it is to get all the issue over again. -1. Get both open & closed tickets sorted by their `created` and `updated` in a descending order. Do not need to get all pages back to UNIX time... -1. If we have a mismatch between our previous arrays of open/closed issue ids then determine if we need to move an issue (change of state) from one group to another. \ No newline at end of file +1. Get [changes](http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository) to tickets doing pagination if need be up to the last check time. +1. If events are closed/opened ones that ref an issue in our milestone & matching pattern then update/add to our collections. \ No newline at end of file diff --git a/src/milestones.coffee b/src/milestones.coffee index 82cfcb5..6fd1b22 100644 --- a/src/milestones.coffee +++ b/src/milestones.coffee @@ -2,8 +2,8 @@ req = require './request' module.exports = - 'get_current': (user, repo, cb) -> - req.milestones user, repo, (err, data) -> + 'get_current': (opts, cb) -> + req.all_milestones opts, (err, data) -> # Request errors. return cb err if err # GitHub errors. diff --git a/src/request.coffee b/src/request.coffee index caf3edc..94aeeda 100644 --- a/src/request.coffee +++ b/src/request.coffee @@ -1,4 +1,6 @@ #!/usr/bin/env coffee module.exports = - 'milestones': (user, repo, cb) -> - cb null, { 'real': 'one' } \ No newline at end of file + 'all_milestones': (opts, cb) -> + cb 'Not implemented' + 'all_issues': (opts, cb) -> + cb 'Not implemented' \ No newline at end of file diff --git a/test/milestones.coffee b/test/milestones.coffee index bd88d16..0a7cd99 100644 --- a/test/milestones.coffee +++ b/test/milestones.coffee @@ -11,7 +11,7 @@ milestones = proxy path.resolve(__dirname, '../src/milestones.coffee'), module.exports = 'get current from 1': (done) -> - req.milestones = (user, repo, cb) -> + req.all_milestones = (opts, cb) -> cb null, [ { 'number': 1 @@ -20,13 +20,13 @@ module.exports = } ] - milestones.get_current null, null, (err, warn, milestone) -> + milestones.get_current {}, (err, warn, milestone) -> assert.ifError err assert.equal milestone.number, 1 done.call null 'get current from > 1': (done) -> - req.milestones = (user, repo, cb) -> + req.all_milestones = (opts, cb) -> cb null, [ { 'number': 1 @@ -45,30 +45,30 @@ module.exports = } ] - milestones.get_current null, null, (err, warn, milestone) -> + milestones.get_current {}, (err, warn, milestone) -> assert.ifError err assert.equal milestone.number, 2 done.call null 'get current when empty': (done) -> - req.milestones = (user, repo, cb) -> + req.all_milestones = (opts, cb) -> cb null, [] - milestones.get_current null, null, (err, warn, milestone) -> + milestones.get_current {}, (err, warn, milestone) -> assert.ifError err assert.equal warn, 'No open milestones for repo' done.call null 'get current when not found': (done) -> - req.milestones = (user, repo, cb) -> + req.all_milestones = (opts, cb) -> cb null, { 'message': 'Not Found' } - milestones.get_current null, null, (err, warn, milestone) -> + milestones.get_current {}, (err, warn, milestone) -> assert.equal err, 'Not Found' done.call null 'get current when no issues': (done) -> - req.milestones = (user, repo, cb) -> + req.all_milestones = (opts, cb) -> cb null, [ { 'number': 1 @@ -79,7 +79,7 @@ module.exports = } ] - milestones.get_current null, null, (err, warn, milestone) -> + milestones.get_current {}, (err, warn, milestone) -> assert.ifError err assert.equal warn, 'No issues for milestone' done.call null \ No newline at end of file