-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #875 from Worktez/dev-angular
Internal Release 7.6
- Loading branch information
Showing
35 changed files
with
887 additions
and
99 deletions.
There are no files selected for viewing
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
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
70 changes: 70 additions & 0 deletions
70
functions/model/performanceChart/tark/getSprintBurndownChart.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* eslint-disable linebreak-style */ | ||
/* eslint-disable max-len */ | ||
/* eslint-disable guard-for-in */ | ||
/* eslint-disable object-curly-spacing */ | ||
|
||
/** ********************************************************* | ||
* Copyright (C) 2022 | ||
* Worktez | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the MIT License | ||
* | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the MIT License for more details. | ||
***********************************************************/ | ||
|
||
const { createSprintName } = require("../../application/lib"); | ||
const { getTeamUseTeamId } = require("../../teams/lib"); | ||
const { getOrganizationsChartDetails } = require("../lib"); | ||
const { updateSprintBurndownChartData } = require("./updateSprintBurndownChart"); | ||
|
||
exports.getSprintBurndownChartData = function(request, response) { | ||
const data = request.body.data; | ||
const orgDomain = data.OrganizationDomain; | ||
const teamId = data.TeamId; | ||
const sprintNumber = parseInt(request.body.data.SprintNumber); | ||
const fullSprintName = createSprintName(sprintNumber); | ||
let result; | ||
let teamName; | ||
let status = 200; | ||
let dataFound = false; | ||
|
||
const sprintEvaluationGraphPromise = getTeamUseTeamId(orgDomain, teamId).then((team) => { | ||
teamName = team.TeamName; | ||
const p1 = getOrganizationsChartDetails(orgDomain, teamName, "SprintBurndownChart").then((doc) => { | ||
let responseData = []; | ||
if (doc == undefined) { | ||
updateSprintBurndownChartData(orgDomain, teamId, fullSprintName); | ||
result = {data: {status: "ERROR", data: "undefined"}}; | ||
} else { | ||
for (const i in doc) { | ||
if (i===fullSprintName) { | ||
const chartData = doc[i]; | ||
responseData = chartData; | ||
dataFound = true; | ||
} | ||
} | ||
if (dataFound == false) { | ||
console.log("got here"); | ||
updateSprintBurndownChartData(orgDomain, teamId, fullSprintName); | ||
} | ||
result = { data: { status: "OK", data: responseData } }; | ||
} | ||
}); | ||
return Promise.resolve(p1); | ||
}).catch((error) => { | ||
status = 500; | ||
console.log("Error:", error); | ||
}); | ||
return Promise.resolve(sprintEvaluationGraphPromise).then(() => { | ||
console.log("Fetched Sprint Burndown Chart Data Successfully"); | ||
return response.status(status).send(result); | ||
}).catch((error) => { | ||
console.error("Error Fetching Sprint Burndown Chart Data", error); | ||
return response.status(status).send(result); | ||
}); | ||
}; |
109 changes: 109 additions & 0 deletions
109
functions/model/performanceChart/tark/updateSprintBurndownChart.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* eslint-disable linebreak-style */ | ||
/* eslint-disable max-len */ | ||
/* eslint-disable object-curly-spacing */ | ||
/* eslint-disable eol-last */ | ||
|
||
/** ********************************************************* | ||
* Copyright (C) 2022 | ||
* Worktez | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the MIT License | ||
* | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the MIT License for more details. | ||
***********************************************************/ | ||
|
||
const { getSprint } = require("../../sprints/lib"); | ||
const { getAllTasks } = require("../../tasks/lib"); | ||
const { getTeamUseTeamId } = require("../../teams/lib"); | ||
const { updateChart, setOrganizationsChart, getOrganizationsChartDetails } = require("../lib"); | ||
|
||
exports.updateSprintBurndownChartData = function(orgDomain, teamId, fullSprintName) { | ||
let totalStoryPoints = 0; | ||
const inputJson = {}; | ||
const tasks = []; | ||
const p1 = getTeamUseTeamId(orgDomain, teamId).then((data)=>{ | ||
const teamName = data.TeamName; | ||
const p2 = getSprint(orgDomain, teamName, fullSprintName).then((sprintDoc)=>{ | ||
const sprintNumber = sprintDoc.SprintNumber; | ||
const sprintStartDate = new Date(sprintDoc.StartDate.replace("/", "-")); | ||
const sprintEndDate = new Date(sprintDoc.EndDate.replace("/", "-")); | ||
const date = new Date(sprintStartDate.getTime()); | ||
const dates = []; | ||
while (date <= sprintEndDate) { | ||
dates.push([new Date(date), 0]); | ||
date.setDate(date.getDate() + 1); | ||
} | ||
const chartData = dates; | ||
|
||
const p = getAllTasks(orgDomain, teamId, sprintNumber).then((taskCol) => { | ||
taskCol.forEach((taskDoc) => { | ||
tasks.push(taskDoc.data()); | ||
}); | ||
|
||
|
||
tasks.forEach((task) => { | ||
const taskCreationDate = new Date(task.CreationDate.replace("/", "-")); | ||
if (taskCreationDate.getTime()<sprintStartDate.getTime()) { | ||
totalStoryPoints += task.StoryPointNumber; | ||
} | ||
}); | ||
|
||
chartData.forEach((element, index) => { | ||
tasks.forEach((task) => { | ||
let formattedDate; | ||
let creationDate; | ||
// To increase story points on task creation | ||
if (task.CreationDate.includes("/")) { | ||
// This condition is added to support the Previous data before the change in the ToolsService, Can be removed in future. | ||
const dateArray = task.CreationDate.split("/"); | ||
creationDate = dateArray[1] + "/" + dateArray[0] + "/" + dateArray[2]; | ||
} else if (task.CreationDate.includes("-")) { | ||
const dateArray = task.CreationDate.split("-"); | ||
creationDate = dateArray[1] + "/" + dateArray[0] + "/" + dateArray[2]; | ||
} | ||
if (new Date(creationDate).toDateString() === element[0].toDateString()) { | ||
totalStoryPoints += task.StoryPointNumber; | ||
} | ||
|
||
// To decrease story points on task completion | ||
|
||
if (task.CompletionDate.includes("/")) { | ||
// This condition is added to support the Previous data before the change in the ToolsService, Can be removed in future. | ||
const dateArray = task.CompletionDate.split("/"); | ||
formattedDate = dateArray[1] + "/" + dateArray[0] + "/" + dateArray[2]; | ||
} else if (task.CompletionDate.includes("-")) { | ||
const dateArray = task.CompletionDate.split("-"); | ||
formattedDate = dateArray[1] + "/" + dateArray[0] + "/" + dateArray[2]; | ||
} | ||
|
||
if (task.Status == "Completed" && new Date(formattedDate).toDateString() === element[0].toDateString()) { | ||
totalStoryPoints -= task.StoryPointNumber; | ||
} | ||
chartData[index] = totalStoryPoints; | ||
}); | ||
}); | ||
|
||
inputJson[fullSprintName] = chartData; | ||
const promise = getOrganizationsChartDetails(orgDomain, teamName, "SprintBurndownChart").then((data) => { | ||
if (data != undefined) { | ||
updateChart(orgDomain, teamName, "SprintBurndownChart", inputJson); | ||
} else { | ||
setOrganizationsChart(orgDomain, teamName, "SprintBurndownChart", inputJson); | ||
} | ||
return null; | ||
}).catch((err) => { | ||
console.log(err); | ||
}); | ||
return Promise.resolve(promise); | ||
}); | ||
return Promise.resolve(p); | ||
}); | ||
return Promise.resolve(p2); | ||
}); | ||
Promise.resolve(p1); | ||
}; |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* eslint-disable linebreak-style */ | ||
/* eslint-disable max-len */ | ||
/* eslint-disable object-curly-spacing */ | ||
/* eslint-disable eol-last */ | ||
|
||
/** ********************************************************* | ||
* Copyright (C) 2022 | ||
* Worktez | ||
* Author: Swapnil Bankar <swapnilbankar1010@gmail.com> | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the MIT License | ||
* | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the MIT License for more details. | ||
***********************************************************/ | ||
|
||
const { updateTeamDetails, getTeam } = require("../lib"); | ||
|
||
exports.addGitToken = function(request, response) { | ||
const orgDomain = request.body.data.OrganizationDomain; | ||
const teamName = request.body.data.TeamName; | ||
const gitToken = request.body.data.GitToken; | ||
|
||
let status = 200; | ||
let result = { data: "Error in updating team" }; | ||
|
||
const promise1 = getTeam(orgDomain, teamName) | ||
.then((team) => { | ||
if (team) { | ||
const updateJson = { | ||
GitToken: gitToken, | ||
}; | ||
updateTeamDetails(updateJson, orgDomain, teamName); | ||
result = { data: "Team Updated Successfully" }; | ||
console.log("Team Updated Successfully"); | ||
} else { | ||
status = 500; | ||
result = { data: "Error: Team doesn't exist" }; | ||
console.log("Error: Team doesn't exist"); | ||
} | ||
}) | ||
.catch((error) => { | ||
status = 500; | ||
console.log("Error: ", error); | ||
}); | ||
|
||
const Promises = [promise1]; | ||
Promise.all(Promises) | ||
.then(() => { | ||
return response.status(status).send(result); | ||
}) | ||
.catch((error) => { | ||
result = { data: error }; | ||
console.error("Error updating Team", error); | ||
return response.status(status).send(result); | ||
}); | ||
}; |
Oops, something went wrong.