switch to opts object

This commit is contained in:
Radek Stepan 2013-08-13 13:05:21 +01:00
parent c9c9650df8
commit b6a0866787
4 changed files with 19 additions and 17 deletions

View File

@ -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.
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.

View File

@ -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.

View File

@ -1,4 +1,6 @@
#!/usr/bin/env coffee
module.exports =
'milestones': (user, repo, cb) ->
cb null, { 'real': 'one' }
'all_milestones': (opts, cb) ->
cb 'Not implemented'
'all_issues': (opts, cb) ->
cb 'Not implemented'

View File

@ -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