when all issues are emptx
This commit is contained in:
parent
b6a0866787
commit
689f6868a8
|
@ -8,7 +8,8 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"coffee-script": "~1.6.3",
|
"coffee-script": "~1.6.3",
|
||||||
"async": "~0.2.9",
|
"async": "~0.2.9",
|
||||||
"proxyquire": "~0.4.1"
|
"proxyquire": "~0.4.1",
|
||||||
|
"lodash": "~1.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"mocha": "~1.12.0"
|
"mocha": "~1.12.0"
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
#!/usr/bin/env coffee
|
||||||
|
{ _ } = require 'lodash'
|
||||||
|
async = require 'async'
|
||||||
|
req = require './request'
|
||||||
|
|
||||||
|
module.exports =
|
||||||
|
# Used on an initial fetch of issues for a repo.
|
||||||
|
'get_all': (opts, cb) ->
|
||||||
|
done = no
|
||||||
|
|
||||||
|
# For each status...
|
||||||
|
one_status = (status, cb) ->
|
||||||
|
# Concat them here.
|
||||||
|
results = []
|
||||||
|
# One pageful fetch (next pages in series).
|
||||||
|
do fetch_page = (page = 1) ->
|
||||||
|
req.all_issues { status: status, page: page }, (err, data) ->
|
||||||
|
# Request errors.
|
||||||
|
return cb err if err
|
||||||
|
# GitHub errors.
|
||||||
|
return cb data.message if data.message
|
||||||
|
# Empty?
|
||||||
|
return cb null, results unless data.length
|
||||||
|
# Concat.
|
||||||
|
results = results.concat data
|
||||||
|
# < 100 results?
|
||||||
|
return cb null, results if data.length < 100
|
||||||
|
# Fetch the next page then.
|
||||||
|
fetch_page page + 1
|
||||||
|
|
||||||
|
# For each `open` and `closed` issues in parallel.
|
||||||
|
async.parallel [
|
||||||
|
_.partial one_status, 'open'
|
||||||
|
_.partial one_status, 'closed'
|
||||||
|
], cb
|
|
@ -2,6 +2,7 @@
|
||||||
req = require './request'
|
req = require './request'
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
|
# Used at initialization stage.
|
||||||
'get_current': (opts, cb) ->
|
'get_current': (opts, cb) ->
|
||||||
req.all_milestones opts, (err, data) ->
|
req.all_milestones opts, (err, data) ->
|
||||||
# Request errors.
|
# Request errors.
|
||||||
|
|
|
@ -3,4 +3,5 @@ module.exports =
|
||||||
'all_milestones': (opts, cb) ->
|
'all_milestones': (opts, cb) ->
|
||||||
cb 'Not implemented'
|
cb 'Not implemented'
|
||||||
'all_issues': (opts, cb) ->
|
'all_issues': (opts, cb) ->
|
||||||
|
# { direction: 'asc', per_page: 100 }
|
||||||
cb 'Not implemented'
|
cb 'Not implemented'
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env coffee
|
||||||
|
assert = require 'assert'
|
||||||
|
async = require 'async'
|
||||||
|
path = require 'path'
|
||||||
|
proxy = require 'proxyquire'
|
||||||
|
|
||||||
|
req = {}
|
||||||
|
|
||||||
|
issues = proxy path.resolve(__dirname, '../src/issues.coffee'),
|
||||||
|
'./request': req
|
||||||
|
|
||||||
|
module.exports =
|
||||||
|
'all empty': (done) ->
|
||||||
|
called = 0
|
||||||
|
req.all_issues = (opts, cb) ->
|
||||||
|
called += 1
|
||||||
|
cb null, []
|
||||||
|
|
||||||
|
issues.get_all {}, (err, [ open, closed ]) ->
|
||||||
|
assert.ifError err
|
||||||
|
assert.equal called, 2
|
||||||
|
assert.equal open.length, 0
|
||||||
|
assert.equal closed.length, 0
|
||||||
|
done.call null
|
Loading…
Reference in New Issue