Skip to content

Commit

Permalink
Merge branch 'dev-angular' into dev-socialPage
Browse files Browse the repository at this point in the history
  • Loading branch information
printf-twinkle authored Feb 5, 2022
2 parents 44b3bcf + 3cf1f76 commit 6eb93b7
Show file tree
Hide file tree
Showing 27 changed files with 221 additions and 74 deletions.
5 changes: 3 additions & 2 deletions functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const { activity } = require("./model/activity/activity");
const { librarian } = require("./model/librarian/librarian");
const { notifications } = require("./model/notifications/notifications");
const { contributors } = require("./model/contributors/contributors");
const { scheduledFn } = require("./model/scheduledFunctions/scheduledFn");
const { scheduledFn, scheduledFnManually } = require("./model/scheduledFunctions/scheduledFn");
const { linker } = require("./model/linker/linker");
const { quickNotes } = require("./model/quickNotes/quickNotes");
const {socialPage} = require("./model/socialPage/socialPage");
Expand All @@ -42,4 +42,5 @@ exports.contributors = contributors;
exports.scheduledFn = scheduledFn;
exports.linker = linker;
exports.quickNotes = quickNotes;
exports.socialPage = socialPage;
exports.socialPage = socialPage;
exports.scheduledFnManually = scheduledFnManually;
14 changes: 13 additions & 1 deletion functions/model/performanceChart/tark/getPerformanceChartData.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const { getOrg } = require("../../organization/lib");
const { setSchedularUnit } = require("../../scheduledFunctions/tark/setSchedular");
const { startSchedular } = require("../../scheduledFunctions/tark/startSchedular");
const { getTeamUseTeamId } = require("../../teams/lib");
const { getOrganizationsChartDetails } = require("../lib");
const { getOrganizationsChartDetails, getUserPerformanceChart } = require("../lib");
const { getUserPerformanceChartData } = require("./getUserPerformanceChartData");
const { getUserUseEmail} = require("../../users/lib");

exports.getPerformanceChartData = function(request, response) {
const data = request.body.data;
Expand All @@ -20,6 +22,7 @@ exports.getPerformanceChartData = function(request, response) {
let result;
let status = 200;

if(assignee=="Team"){
const performanceChartDataPromise = getTeamUseTeamId(orgDomain, teamId).then((team) => {
teamName = team.TeamName;
const p1 = getOrganizationsChartDetails(orgDomain, teamName, "PerformanceChart").then((doc) => {
Expand Down Expand Up @@ -50,4 +53,13 @@ exports.getPerformanceChartData = function(request, response) {
console.error("Error Fetching Performance Chart Data", error);
return response.status(status).send(result);
});
} else {
getUserUseEmail(assignee).then((data)=>{
if (data!=undefined){
const uid=data.uid
request.body.data.Uid = uid
getUserPerformanceChartData(request, response)
}
});
}
};
22 changes: 19 additions & 3 deletions functions/model/scheduledFunctions/scheduledFn.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,28 @@
// const { getUserPerformanceChart } = require("./lib");
// const { updatedUserPerformanceChartData } = require("./updatedUserPerformanceChartData");

const { functions, cors } = require("../application/lib");

const { functions, cors, fastify, requestHandler } = require("../application/lib");
const { addSchedularOrg } = require("./tark/addSchedular");
const { startSchedular } = require("./tark/startSchedular");

// exports.scheduledFn = functions.https.onRequest((req, res) => {
// cors(req, res, () => {
exports.scheduledFn = functions.pubsub.schedule("1 21 * * *").onRun((context) => {
startSchedular();
exports.scheduledFn = functions.pubsub.schedule("1 21 * * *").onRun((context) => {
startSchedular();
});
// });
// });

fastify.post("/addScheduler", (req, res) => {
addSchedularOrg(req, res);
});

exports.scheduledFnManually = functions.https.onRequest((req, res) => {
cors(req, res, () => {
fastify.ready((err) => {
if (err) throw err;
requestHandler(req, res);
});
});
});
3 changes: 3 additions & 0 deletions functions/model/scheduledFunctions/tark/startSchedular.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { updatePerformanceChartData } = require("../../performanceChart/tark/upda
const { updateSprintEvaluationGraphData } = require("../../performanceChart/tark/updateSprintEvaluationGraph");
const { getTeamUseTeamId } = require("../../teams/lib");
const { getAllSchedular } = require("../lib");
const { updateAutoSprintStatus } = require("../../sprints/tark/updateAutoSprintStatus");

exports.startSchedular = function() {
getAllSchedular().then((sched) => {
Expand All @@ -30,6 +31,8 @@ exports.startSchedular = function() {
updatedUserPerformanceChartData(schDoc.data().OrgDomain, schDoc.data().Assignee, sprintRange);
} else if (type == "PerformanceChart") {
updatePerformanceChartData(schDoc.data().OrgDomain, schDoc.data().TeamId, schDoc.data().Assignee, sprintRange);
} else if (type == "AutoSprintCompletion") {
updateAutoSprintStatus(schDoc.data().OrgAppKey, schDoc.data().TeamId);
}
}).catch((error)=>{
console.log("Error:", error);
Expand Down
59 changes: 59 additions & 0 deletions functions/model/sprints/tark/updateAutoSprintStatus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* eslint-disable linebreak-style */
/* eslint-disable require-jsdoc */
/* eslint-disable object-curly-spacing*/
// /* eslint-disable no-undef */
/* eslint-disable eol-last */
/* eslint-disable indent */
/* eslint-disable max-len */
// eslint-disable-next-line no-dupe-else-if

const { getOrgUseAppKey } = require("../../organization/lib");
const { getTeamUseTeamId } = require("../../teams/lib");
const { updateSprint, getSprint } = require("../lib");


exports.updateAutoSprintStatus = function(appKey, teamId) {

let orgDomain;
let result;
let status = 200;
let today = new Date();
var currentDate = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();;

const updateSprintPromise = getOrgUseAppKey(appKey).then((orgDoc) => {
orgDomain = orgDoc.OrganizationDomain;

const updateTeamSprintStatus = getTeamUseTeamId(orgDomain, teamId).then((teamDoc) => {
const teamName = teamDoc.TeamName;
const currentSprintName = 'S' + teamDoc.CurrentSprintId;

let updateSprintStatusInputJson;
const getSprintPromise = getSprint(orgDomain, teamName, currentSprintName).then((sprintDoc) => {
console.log(currentDate);
console.log(sprintDoc.EndDate);
if (currentDate >= sprintDoc.EndDate) {
updateSprintStatusInputJson = {
Status: "Completed"
};
updateSprint(updateSprintStatusInputJson, orgDomain, teamName, currentSprintName);
}
});
return Promise.resolve(getSprintPromise);
}).catch((error) => {
status = 500;
console.log("Error:", error);
});
console.log("Sprint updated successfully");
result = { data: "OK" };
return Promise.resolve(updateTeamSprintStatus);
});
return Promise.resolve(updateSprintPromise).then(() => {
result = { data: "Sprint Updated Successfully" };
console.log("Sprint Updated Successfully");
return result;
}).catch((error) => {
result = { data: error };
console.error("Error Updating Sprint", error);
return result;
});
};
4 changes: 3 additions & 1 deletion functions/model/tasks/tark/addComment.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ exports.addComment = function(request, response) {
const notificationMessage = senderName + " has commented on task " + taskId;
const subjectMessage = senderName + " has commented on task " + taskId;

const htmlMessage = "<div style=\"background-color:#E9ECEF;margin:auto;width:80%;padding-top: 30px;height:100%;\"><table style=\"background-color:#ffffff;height:80%;width:80%;margin:auto;\"><tr><td><img src=\"https://worktez.com/assets/logo.png\" style=\"height:50%;width:50%;display:block;margin:auto;\" alt=\"worktez logo\"></td></tr><tr><td><h2 style=\"text-align:center;\">Welcome to Worktez</h2></td></tr><tr><td style=\"padding-left:30px;text-align:center;\"><p>" + "Hi " + assigneeName + "<br>" + notificationMessage + "</p></td></tr><tr style=\"text-align:center;\" rowspan=\"1\"><td><a href=\"https://worktez.com/TaskDetails/" + taskId + "\" target=\"_blank\" style=\"background-color: #dc3226; color: white; text-decoration:none; padding: 15px;border-radius:50px;border:red;cursor:pointer;\">View comment</a><p style=\"color:#666;\">Please click the button to view the comment.</p></td></tr><tr><td></td></tr></table><div style=\"text-align:center;padding:20px;\"><p style=\"color:#666;\">Show us some love. Like & Follow us. Spread the word about Worktez.</p><a href=\"https://www.linkedin.com/company/worktez/\" target=\"_blank\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" class=\"bi bi-linkedin\" viewBox=\"0 0 16 16\" style=\"margin-left:10px;cursor:pointer;\"><path d=\"M0 1.146C0 .513.526 0 1.175 0h13.65C15.474 0 16 .513 16 1.146v13.708c0 .633-.526 1.146-1.175 1.146H1.175C.526 16 0 15.487 0 14.854V1.146zm4.943 12.248V6.169H2.542v7.225h2.401zm-1.2-8.212c.837 0 1.358-.554 1.358-1.248-.015-.709-.52-1.248-1.342-1.248-.822 0-1.359.54-1.359 1.248 0 .694.521 1.248 1.327 1.248h.016zm4.908 8.212V9.359c0-.216.016-.432.08-.586.173-.431.568-.878 1.232-.878.869 0 1.216.662 1.216 1.634v3.865h2.401V9.25c0-2.22-1.184-3.252-2.764-3.252-1.274 0-1.845.7-2.165 1.193v.025h-.016a5.54 5.54 0 0 1 .016-.025V6.169h-2.4c.03.678 0 7.225 0 7.225h2.4z\"/></svg></a><a href=\"https://github.com/Worktez/worktez\" target=\"_blank\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" class=\"bi bi-github\" viewBox=\"0 0 16 16\" style=\"margin-left:10px;cursor:pointer;\"><path d=\"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z\"/></svg></a></div></div>";
const htmlMessage = "<div style=\"background-color:#E9ECEF;margin:auto;width:80%;padding-top: 30px;height:100%;\">" +
"<table style=\"background-color:#ffffff;height:80%;width:80%;margin:auto;\"><tr><td><img src=\"https://worktez.com/assets/logo.png\" style=\"height:50%;width:50%;display:block;margin:auto;\" alt=\"worktez logo\"></td></tr>" +
"<tr><td><h2 style=\"text-align:center;\">Welcome to Worktez</h2></td></tr>" + "<tr><td style=\"padding-left:30px;text-align:center;\"><p>" + "Hi " + assigneeName + "<br>" + notificationMessage + "</p></td></tr><tr style=\"text-align:center;\" rowspan=\"1\"><td><a href=\"https://worktez.com/TaskDetails/" + taskId + "\" target=\"_blank\" style=\"background-color: #dc3226; color: white; text-decoration:none; padding: 15px;border-radius:50px;border:red;cursor:pointer;\">View comment</a><p style=\"color:#666;\">Please click the button to view the comment.</p></td></tr><tr><td></td></tr></table>" + "<div style=\"text-align:center;padding:20px;\">" + "<p style=\"color:#666;\">Show us some love. Like & Follow us. Spread the word about Worktez.</p><a href=\"https://www.linkedin.com/company/worktez/\" target=\"_blank\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" class=\"bi bi-linkedin\" viewBox=\"0 0 16 16\" style=\"margin-left:10px;cursor:pointer;\"><path d=\"M0 1.146C0 .513.526 0 1.175 0h13.65C15.474 0 16 .513 16 1.146v13.708c0 .633-.526 1.146-1.175 1.146H1.175C.526 16 0 15.487 0 14.854V1.146zm4.943 12.248V6.169H2.542v7.225h2.401zm-1.2-8.212c.837 0 1.358-.554 1.358-1.248-.015-.709-.52-1.248-1.342-1.248-.822 0-1.359.54-1.359 1.248 0 .694.521 1.248 1.327 1.248h.016zm4.908 8.212V9.359c0-.216.016-.432.08-.586.173-.431.568-.878 1.232-.878.869 0 1.216.662 1.216 1.634v3.865h2.401V9.25c0-2.22-1.184-3.252-2.764-3.252-1.274 0-1.845.7-2.165 1.193v.025h-.016a5.54 5.54 0 0 1 .016-.025V6.169h-2.4c.03.678 0 7.225 0 7.225h2.4z\"/></svg></a><a href=\"https://github.com/Worktez/worktez\" target=\"_blank\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" class=\"bi bi-github\" viewBox=\"0 0 16 16\" style=\"margin-left:10px;cursor:pointer;\"><path d=\"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z\"/></svg></a></div></div>";

addActivity("COMMENT", logWorkComment, taskId, date, time, orgDomain, uid);
sendMail(assignee, subjectMessage, htmlMessage);
Expand Down
Loading

0 comments on commit 6eb93b7

Please sign in to comment.