Skip to content

Commit

Permalink
Fix Error checking bug once time is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilyheart committed Dec 4, 2019
1 parent 3cb568e commit b3b27c0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ <h4 class="d-inline-flex">Warnings</h4>
<script type="text/javascript" src="libraries/defiant.min.js?ver=v2.2.6"></script>
<script type="text/javascript" src="scripts/projects.js?ver=0.2.7"></script>
<script type="text/javascript" src="scripts/issues.js?ver=0.2.7"></script>
<script type="text/javascript" src="scripts/burndown.js?ver=0.2.7"></script>
<script type="text/javascript" src="scripts/burndown.js?ver=0.2.7c"></script>
<script type="text/javascript" src="scripts/hours.js?ver=0.2.7"></script>
<script type="text/javascript" src="gitlab_servers.js?ver=0.2.7"></script>
<script type="text/javascript" src="scripts/main.js?ver=0.2.7"></script>
Expand Down
26 changes: 19 additions & 7 deletions scripts/burndown.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ var burndown = (function () {
let filteredJSON, chartSeries;

// for each note, determine if it's from an issue of interest
if (filter !== null) {
// eslint-disable-next-line no-undefined
if (filter !== undefined) {
filteredJSON = source.filter(row => milestoneList[filter[1]].issues.includes(row.issue));
} else {
filteredJSON = source;
Expand Down Expand Up @@ -288,12 +289,6 @@ var burndown = (function () {
}
}
tempSpentTimeList.push({date: date, spent: spent, issue: noteableIID, author: note.author.name});

// **************************** CHECK DATE ****************************

if (new Date(date) < currProjStartDate) {
issues.addIssueError(issueListJSON[noteableIID], "Spend prior to project's creation date");
}
}

// If time spent was removed
Expand Down Expand Up @@ -349,6 +344,23 @@ var burndown = (function () {
spentTimeList = spentTimeList.concat(tempSpentTimeList);
estimateTimeList = estimateTimeList.concat(tempEstTimeList);

tempSpentTimeList = spentTimeList.reduce((acc, cur) => {
acc[cur.issue + "-" + cur.date] = acc[cur.issue + "-" + cur.date] || {date: cur.date, issue: cur.issue, spent: 0};
acc[cur.issue + "-" + cur.date].spent += +cur.spent;

return acc;
}, {});

for (let issue in tempSpentTimeList) {
if (tempSpentTimeList.hasOwnProperty(issue)) {
// **************************** CHECK DATE ****************************
if (tempSpentTimeList[issue].spent > 0 && new Date(tempSpentTimeList[issue].date) < currProjStartDate) {
noteableIID = tempSpentTimeList[issue].issue;
issues.addIssueError(issueListJSON[noteableIID], "Spend prior to project's creation date");
}
}
}

// *************************** END OF NOTE LOOP ***************************

// Spent Sanity check
Expand Down

0 comments on commit b3b27c0

Please sign in to comment.