in src/server/api/cla.js [211:259]
async validateAllPullRequests(req, item) {
let pullRequests = []
const token = req.args.token ? req.args.token : req.user.token
try {
const resp = await github.call({
obj: 'pulls',
fun: 'list',
arg: {
owner: req.args.owner,
repo: req.args.repo,
state: 'open',
per_page: 100
},
token
})
pullRequests = resp.data
} catch (error) {
logger.error(new Error(error).stack)
}
if (pullRequests.length > 0) {
const args = {
repo: req.args.repo,
owner: req.args.owner,
token: token
}
try {
if (!item) {
item = await cla.getLinkedItem(args)
}
} catch (error) {
throw new Error(`could not find linked item for owner ${args.owner} and repo ${args.repo}`)
}
// const promises = pullRequests.map((pullRequest, index) => {
pullRequests.map((pullRequest, index) => {
const status_args = JSON.parse(JSON.stringify(args))
status_args.number = pullRequest.number
status_args.sha = pullRequest.head.sha
setTimeout(() => {
this.validatePullRequest(status_args, item)
logger.info('validateRepoPRs for ' + status_args.owner + '/' + status_args.repo)
}, global.config.server.github.timeToWait * (index + (Math.floor(index / 10) * 10)))
})
// return Promise.all(promises)
}
return []
}