mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-03-12 22:30:00 +00:00
effective streak counting
This commit is contained in:
parent
670e83a843
commit
c2db37b285
@ -33,26 +33,34 @@ module.exports = function(app) {
|
|||||||
status: 'done',
|
status: 'done',
|
||||||
descCreateDate: ''
|
descCreateDate: ''
|
||||||
},
|
},
|
||||||
limit: 20
|
limit: 10
|
||||||
}, this.slot());
|
}, this.slot());
|
||||||
|
|
||||||
// get last builds to calc current success streak
|
// tricky but effective streak counting inside filter goes below
|
||||||
var isAllPrevDone = true;
|
var doneBuildsStreakCallback = _(this.slot()).once(),
|
||||||
db.builds.count({
|
doneBuildsStreak = 0;
|
||||||
|
|
||||||
|
db.builds.find({
|
||||||
start: {
|
start: {
|
||||||
projectName: project.name,
|
projectName: project.name,
|
||||||
descCreateDate: ''
|
descCreateDate: ''
|
||||||
},
|
},
|
||||||
// TODO: find should be implemented at nlevel
|
|
||||||
filter: function(build) {
|
filter: function(build) {
|
||||||
if (isAllPrevDone && build.status === 'error') {
|
// error exits streak
|
||||||
isAllPrevDone = false;
|
if (build.status === 'error') {
|
||||||
|
doneBuildsStreakCallback(null, doneBuildsStreak);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return isAllPrevDone && build.status === 'done';
|
if (build.status === 'done') {
|
||||||
}
|
doneBuildsStreak++;
|
||||||
}, this.slot());
|
}
|
||||||
|
},
|
||||||
|
limit: 1
|
||||||
|
}, function(err) {
|
||||||
|
doneBuildsStreakCallback(err, doneBuildsStreak);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
function(err, doneBuilds, doneBuildsCount) {
|
function(err, doneBuilds, doneBuildsStreak) {
|
||||||
project.lastDoneBuild = doneBuilds[0];
|
project.lastDoneBuild = doneBuilds[0];
|
||||||
|
|
||||||
var durationsSum = _(doneBuilds).reduce(function(memo, build) {
|
var durationsSum = _(doneBuilds).reduce(function(memo, build) {
|
||||||
@ -63,7 +71,7 @@ module.exports = function(app) {
|
|||||||
durationsSum / doneBuilds.length
|
durationsSum / doneBuilds.length
|
||||||
);
|
);
|
||||||
|
|
||||||
project.doneBuildsStreak = doneBuildsCount
|
project.doneBuildsStreak = doneBuildsStreak;
|
||||||
|
|
||||||
res.send(project);
|
res.send(project);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user