Skip to content

Commit

Permalink
Fix velocity calculation on project dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
vitortalaia committed Oct 9, 2017
1 parent b11270f commit 00a8337
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions app/assets/javascripts/models/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,27 +220,17 @@ module.exports = Backbone.Model.extend({
} else {
// TODO Make number of iterations configurable
var numIterations = 3;
var iterations = [];
var doneIterations = this.doneIterations();
var lastDoneIndex = doneIterations.length - 1;

// Take a maximum of numIterations from the end of the array
// factor out iterations with 0 points
while(numIterations > 0 && lastDoneIndex >= 0) {
var iteration = doneIterations[lastDoneIndex];
if(iteration.points() > 0) {
iterations.push(iteration);
numIterations --;
}
lastDoneIndex --;
}
var iterations = _.last(doneIterations, numIterations);

var velocity = 1;
var pointsArray = _.invoke(iterations, 'points');
if(pointsArray.length > 0) {

if (pointsArray.length > 0) {
var sum = _.reduce(pointsArray, function(memo, points) {
return memo + points;
}, 0);

velocity = Math.floor(sum / pointsArray.length);
}

Expand Down

0 comments on commit 00a8337

Please sign in to comment.