Created
March 5, 2016 02:00
-
-
Save chenbojian/99cd6b9c93e8f94cd4aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Defer() { | |
this.promise = new Promise((resolve, reject) => { | |
this.resolve = resolve; | |
this.reject = this.reject; | |
}); | |
} | |
var promises = []; | |
var pipelineName = 'XXXXXXXX';//replace | |
for(let i = 0; i < 100; i+=10){ | |
let defer = new Defer(); | |
jQuery.get(`/go/api/stages/${pipelineName}/Regression/history/${i}`).then(data => defer.resolve(data.stages), () => console.error('retry!')); | |
promises.push(defer.promise); | |
} | |
Promise.all(promises).then( datas => { | |
let stageHistories = _.reduce(datas, (prev, curr) => prev.concat(curr), []); | |
let groupedStageHistories = _(stageHistories).groupBy('pipeline_counter').map(g => _.max(g, 'counter')).sortBy('pipeline_counter').value(); | |
console.log(groupedStageHistories) | |
_.forEach(groupedStageHistories, h => { | |
console.log(`pipeline: ${h.pipeline_counter} triggered: ${h.counter} final status: ${h.result}`); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment