Skip to content

Commit 7f73cfb

Browse files
author
Harshit Kedia
committed
remove review more pr, fix date bugs
1 parent c354061 commit 7f73cfb

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

src/scripts/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ function handleGsocClick(){
136136
}
137137
enableToggleElement.addEventListener("change", handleEnableChange);
138138
githubUsernameElement.addEventListener("keyup", handleGithubUsernameChange);
139-
startingDateElement.addEventListener("keyup", handleStartingDateChange);
140-
endingDateElement.addEventListener("keyup", handleEndingDateChange);
139+
startingDateElement.addEventListener("change", handleStartingDateChange);
140+
endingDateElement.addEventListener("change", handleEndingDateChange);
141141
lastWeekContributionElement.addEventListener("change", handleLastWeekContributionChange);
142142
showOpenLabelElement.addEventListener("change", handleOpenLabelChange);
143143
userReasonElement.addEventListener("keyup", handleUserReasonChange);

src/scripts/scrumHelper.js

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function allIncluded(){
1111
var nextWeekArray=[];
1212
var reviewedPrsArray=[];
1313
var githubIssuesData=null;
14+
var lastWeekContribution = false;
1415
var githubPrsReviewData=null;
1516
var githubUserData=null;
1617
var githubPrsReviewDataProccessed = {};
@@ -27,21 +28,26 @@ var issue_opened_button="<div style=\"vertical-align:middle;display: inline-bloc
2728

2829
var linkStyle="";
2930
function getChromeData(){
30-
chrome.storage.local.get(["githubUsername","enableToggle","startingDate","endingDate","showOpenLabel","showClosedLabel","userReason","gsoc"],function(items){
31+
chrome.storage.local.get(["githubUsername","enableToggle","startingDate","endingDate","showOpenLabel","showClosedLabel","lastWeekContribution","userReason","gsoc"],function(items){
32+
if(items.lastWeekContribution){
33+
lastWeekContribution = true;
34+
handleLastWeekContributionChange();
35+
}
3136
if(!items.enableToggle){
3237
enableToggle=items.enableToggle;
3338

3439
}
35-
if(items.endingDate){
40+
if(items.endingDate && !lastWeekContribution){
3641
endingDate= items.endingDate;
3742
}
38-
if(items.startingDate){
43+
if(items.startingDate && !lastWeekContribution){
3944
startingDate= items.startingDate;
4045
}
4146
if(items.githubUsername){
4247
githubUsername=items.githubUsername;
4348
fetchGithubData();
4449
}
50+
4551
if(!items.showOpenLabel){
4652
showOpenLabel=false;
4753
pr_unmerged_button="";
@@ -67,6 +73,30 @@ function getChromeData(){
6773
});
6874
}
6975
getChromeData();
76+
77+
function handleLastWeekContributionChange(){
78+
endingDate=getToday();
79+
startingDate=getLastWeek();
80+
}
81+
function getLastWeek(){
82+
var today = new Date();
83+
var noDays_to_goback=gsoc==0?7:1;
84+
var lastWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - noDays_to_goback);
85+
var lastWeekMonth = lastWeek.getMonth() + 1;
86+
var lastWeekDay = lastWeek.getDate();
87+
var lastWeekYear = lastWeek.getFullYear();
88+
var lastWeekDisplayPadded =("0000" + lastWeekYear .toString()).slice(-4) +"-" + ("00" + lastWeekMonth.toString()).slice(-2)+ "-" + ("00" + lastWeekDay .toString()).slice(-2);
89+
return lastWeekDisplayPadded;
90+
}
91+
function getToday(){
92+
var today = new Date();
93+
var Week = new Date(today.getFullYear(), today.getMonth(), today.getDate());
94+
var WeekMonth = Week.getMonth() + 1;
95+
var WeekDay = Week.getDate();
96+
var WeekYear = Week.getFullYear();
97+
var WeekDisplayPadded =("0000" + WeekYear .toString()).slice(-4) +"-" + ("00" + WeekMonth.toString()).slice(-2)+ "-" + ("00" + WeekDay .toString()).slice(-2);
98+
return WeekDisplayPadded;
99+
}
70100
// fetch github data
71101
function fetchGithubData(){
72102
console.log(startingDate);
@@ -127,9 +157,6 @@ function writeScrumBody(){
127157
var nextWeekUl="<ul>";
128158
for(i =0;i<nextWeekArray.length;i++)
129159
nextWeekUl+=nextWeekArray[i];
130-
for(i in githubPrsReviewDataProccessed){
131-
nextWeekUl+="<li><i>("+i+")</i> - Review more PRs </li>";
132-
}
133160
nextWeekUl+="</ul>";
134161
var weekOrDay = gsoc==1?"yesterday":"last week";
135162
var weekOrDay2= gsoc==1?"today":"this week";

0 commit comments

Comments
 (0)