From 35dbdae56da0235867c635054cc198878ab767ba Mon Sep 17 00:00:00 2001 From: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com> Date: Fri, 28 Mar 2025 04:21:37 +0530 Subject: [PATCH 1/5] adding time in calculations of yesterday and today Signed-off-by: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com> --- src/scripts/scrumHelper.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/scripts/scrumHelper.js b/src/scripts/scrumHelper.js index 785fab0..7e97769 100644 --- a/src/scripts/scrumHelper.js +++ b/src/scripts/scrumHelper.js @@ -104,7 +104,10 @@ function allIncluded() { function getLastWeek() { var today = new Date(); var noDays_to_goback = gsoc == 0 ? 7 : 1; - var lastWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - noDays_to_goback); + var lastWeek = new Date(today); + lastWeek.setDate(today.getDate() - noDays_to_goback); + lastWeek.setHours(0, 0, 0, 0); + var lastWeekMonth = lastWeek.getMonth() + 1; var lastWeekDay = lastWeek.getDate(); var lastWeekYear = lastWeek.getFullYear(); @@ -113,21 +116,24 @@ function allIncluded() { '-' + ('00' + lastWeekMonth.toString()).slice(-2) + '-' + - ('00' + lastWeekDay.toString()).slice(-2); + ('00' + lastWeekDay.toString()).slice(-2) + + 'T00:00:00Z'; return lastWeekDisplayPadded; } function getToday() { var today = new Date(); - var Week = new Date(today.getFullYear(), today.getMonth(), today.getDate()); - var WeekMonth = Week.getMonth() + 1; - var WeekDay = Week.getDate(); - var WeekYear = Week.getFullYear(); + today.setHours(23, 59, 59, 999); + // var Week = new Date(today.getFullYear(), today.getMonth(), today.getDate()); + var WeekMonth = today.getMonth() + 1; + var WeekDay = today.getDate(); + var WeekYear = today.getFullYear(); var WeekDisplayPadded = ('0000' + WeekYear.toString()).slice(-4) + '-' + ('00' + WeekMonth.toString()).slice(-2) + '-' + - ('00' + WeekDay.toString()).slice(-2); + ('00' + WeekDay.toString()).slice(-2) + + 'T23:59:59Z'; return WeekDisplayPadded; } // fetch github data From 1f7981b44d51e45b21435f116e579e195239684d Mon Sep 17 00:00:00 2001 From: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com> Date: Fri, 28 Mar 2025 11:44:57 +0530 Subject: [PATCH 2/5] correcting date calulation Signed-off-by: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com> --- src/scripts/scrumHelper.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/scripts/scrumHelper.js b/src/scripts/scrumHelper.js index 7e97769..7abbc7e 100644 --- a/src/scripts/scrumHelper.js +++ b/src/scripts/scrumHelper.js @@ -104,8 +104,7 @@ function allIncluded() { function getLastWeek() { var today = new Date(); var noDays_to_goback = gsoc == 0 ? 7 : 1; - var lastWeek = new Date(today); - lastWeek.setDate(today.getDate() - noDays_to_goback); + var lastWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - noDays_to_goback); lastWeek.setHours(0, 0, 0, 0); var lastWeekMonth = lastWeek.getMonth() + 1; @@ -123,18 +122,19 @@ function allIncluded() { function getToday() { var today = new Date(); today.setHours(23, 59, 59, 999); - // var Week = new Date(today.getFullYear(), today.getMonth(), today.getDate()); - var WeekMonth = today.getMonth() + 1; - var WeekDay = today.getDate(); - var WeekYear = today.getFullYear(); - var WeekDisplayPadded = - ('0000' + WeekYear.toString()).slice(-4) + + var week = new Date(today.getFullYear(), today.getMonth(), today.getDate()); + week.setHours(23, 59, 59, 999); + var weekMonth = week.getMonth() + 1; + var weekDay = week.getDate(); + var weekYear = week.getFullYear(); + var weekDisplayPadded = + ('0000' + weekYear.toString()).slice(-4) + '-' + - ('00' + WeekMonth.toString()).slice(-2) + + ('00' + weekMonth.toString()).slice(-2) + '-' + - ('00' + WeekDay.toString()).slice(-2) + + ('00' + weekDay.toString()).slice(-2) + 'T23:59:59Z'; - return WeekDisplayPadded; + return weekDisplayPadded; } // fetch github data function fetchGithubData() { From 59c8c4aeb5376c78981a8b5f198f9269f263bfe9 Mon Sep 17 00:00:00 2001 From: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com> Date: Mon, 31 Mar 2025 00:28:10 -1200 Subject: [PATCH 3/5] potential fix Signed-off-by: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com> --- src/scripts/scrumHelper.js | 42 +++++++++++++++----------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/src/scripts/scrumHelper.js b/src/scripts/scrumHelper.js index 7abbc7e..04c41db 100644 --- a/src/scripts/scrumHelper.js +++ b/src/scripts/scrumHelper.js @@ -101,41 +101,33 @@ function allIncluded() { endingDate = getToday(); startingDate = getLastWeek(); } + + function getUTCDate(date) { + return new Date(Date.UTC( + date.getFullYear(), + date.getMonth(), + date.getDate(), + date.getHours(), + date.getMinutes(), + date.getSeconds(), + date.getMilliseconds(), + )).toISOString().slice(0,19) + "Z"; + } + function getLastWeek() { var today = new Date(); var noDays_to_goback = gsoc == 0 ? 7 : 1; var lastWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - noDays_to_goback); lastWeek.setHours(0, 0, 0, 0); - var lastWeekMonth = lastWeek.getMonth() + 1; - var lastWeekDay = lastWeek.getDate(); - var lastWeekYear = lastWeek.getFullYear(); - var lastWeekDisplayPadded = - ('0000' + lastWeekYear.toString()).slice(-4) + - '-' + - ('00' + lastWeekMonth.toString()).slice(-2) + - '-' + - ('00' + lastWeekDay.toString()).slice(-2) + - 'T00:00:00Z'; - return lastWeekDisplayPadded; + return getUTCDate(lastWeek); } function getToday() { var today = new Date(); today.setHours(23, 59, 59, 999); - var week = new Date(today.getFullYear(), today.getMonth(), today.getDate()); - week.setHours(23, 59, 59, 999); - var weekMonth = week.getMonth() + 1; - var weekDay = week.getDate(); - var weekYear = week.getFullYear(); - var weekDisplayPadded = - ('0000' + weekYear.toString()).slice(-4) + - '-' + - ('00' + weekMonth.toString()).slice(-2) + - '-' + - ('00' + weekDay.toString()).slice(-2) + - 'T23:59:59Z'; - return weekDisplayPadded; - } + + return getUTCDate(today); + } // fetch github data function fetchGithubData() { var issueUrl = From 8cddb5e9b7b933d84981a5a21541e40f3cd6fc11 Mon Sep 17 00:00:00 2001 From: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com> Date: Mon, 31 Mar 2025 05:06:47 -1200 Subject: [PATCH 4/5] fix 2 Signed-off-by: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com> --- src/scripts/main.js | 32 ++++++++++++++----------- src/scripts/scrumHelper.js | 49 +++++++++++++++++++++++++++----------- 2 files changed, 53 insertions(+), 28 deletions(-) diff --git a/src/scripts/main.js b/src/scripts/main.js index f1ff385..0f50ebd 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -99,9 +99,11 @@ function getLastWeek() { var today = new Date(); var noDays_to_goback = gsoc == 0 ? 7 : 1; var lastWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - noDays_to_goback); - var lastWeekMonth = lastWeek.getMonth() + 1; - var lastWeekDay = lastWeek.getDate(); - var lastWeekYear = lastWeek.getFullYear(); + lastWeek.setHours(0, 0, 0 , 0); + var extendedLastWeek = new Date(lastWeek.getTime() + (14 *60 *60 * 1000)); + var lastWeekMonth = extendedLastWeek.getMonth() + 1; + var lastWeekDay = extendedLastWeek.getDate(); + var lastWeekYear = extendedLastWeek.getFullYear(); var lastWeekDisplayPadded = ('0000' + lastWeekYear.toString()).slice(-4) + '-' + @@ -112,17 +114,19 @@ function getLastWeek() { } function getToday() { var today = new Date(); - var Week = new Date(today.getFullYear(), today.getMonth(), today.getDate()); - var WeekMonth = Week.getMonth() + 1; - var WeekDay = Week.getDate(); - var WeekYear = Week.getFullYear(); - var WeekDisplayPadded = - ('0000' + WeekYear.toString()).slice(-4) + - '-' + - ('00' + WeekMonth.toString()).slice(-2) + - '-' + - ('00' + WeekDay.toString()).slice(-2); - return WeekDisplayPadded; + var today = new Date(today.getFullYear(), today.getMonth(), today.getDate()); + today.setHours(23, 59, 59, 999); + var extendedToday = new Date(today.getTime() + (14 * 60 * 60 * 1000)); + var todayMonth = extendedToday.getMonth() + 1; + var todayDay = extendedToday.getDate(); + var todayYear = extendedToday.getFullYear(); + var todayDisplayPadded = + ('0000' + todayYear.toString()).slice(-4) + + '-' + + ('00' + todayMonth.toString()).slice(-2) + + '-' + + ('00' + todayDay.toString()).slice(-2); + return todayDisplayPadded; } function handleGithubUsernameChange() { diff --git a/src/scripts/scrumHelper.js b/src/scripts/scrumHelper.js index 04c41db..27721e2 100644 --- a/src/scripts/scrumHelper.js +++ b/src/scripts/scrumHelper.js @@ -102,31 +102,23 @@ function allIncluded() { startingDate = getLastWeek(); } - function getUTCDate(date) { - return new Date(Date.UTC( - date.getFullYear(), - date.getMonth(), - date.getDate(), - date.getHours(), - date.getMinutes(), - date.getSeconds(), - date.getMilliseconds(), - )).toISOString().slice(0,19) + "Z"; - } - function getLastWeek() { var today = new Date(); var noDays_to_goback = gsoc == 0 ? 7 : 1; var lastWeek = new Date(today.getFullYear(), today.getMonth(), today.getDate() - noDays_to_goback); lastWeek.setHours(0, 0, 0, 0); - return getUTCDate(lastWeek); + const utc = new Date(lastWeek.getTime() + (14 * 60* 60* 1000)); + + return utc.toISOString().slice(0,19) + "Z"; } function getToday() { var today = new Date(); today.setHours(23, 59, 59, 999); + + const utc = new Date(today.getTime() + (14 * 60 * 60 * 1000)); - return getUTCDate(today); + return utc.toISOString().slice(0, 19) + "Z"; } // fetch github data function fetchGithubData() { @@ -183,6 +175,35 @@ function allIncluded() { githubUserData = data; }, }); + filterAndStoreData(); + } + + function filterDataByDate(data){ + var today = new Date(); + var noDays_to_goback = gsoc == 0 ? 7 : 1; + + const localStart = new Date(today.getFullYear(), today.getMonth(), today.getDate() - noDays_to_goback); + localStart.setHours(0, 0, 0, 0); + + const localEnd = new Date(); + localEnd.setHours(23, 59, 59 ,999); + + return data.items.filter(item => { + const updatedAt = new Date(item.updated_at); + return updatedAt >= localStart && updatedAt <= localEnd; + }) + } + + function filterAndStoreData() { + if(githubIssuesData) { + githubIssuesData.items = filterDataByDate(githubIssuesData); + } + if(githubPrsReviewData) { + githubPrsReviewData.items = filterDataByDate(githubPrsReviewData); + } + if(githubUserData) { + githubUserData.items = filterDataByDate(githubUserData); + } } function formatDate(dateString) { From a328c33d4a344afdb56ab1e0245d26c3d22e9f91 Mon Sep 17 00:00:00 2001 From: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com> Date: Mon, 31 Mar 2025 08:50:15 -1200 Subject: [PATCH 5/5] fix 3 Signed-off-by: Vedansh Saini <77830698+vedansh-5@users.noreply.github.com> --- src/scripts/scrumHelper.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/scripts/scrumHelper.js b/src/scripts/scrumHelper.js index 27721e2..8e4e220 100644 --- a/src/scripts/scrumHelper.js +++ b/src/scripts/scrumHelper.js @@ -120,6 +120,7 @@ function allIncluded() { return utc.toISOString().slice(0, 19) + "Z"; } + // fetch github data function fetchGithubData() { var issueUrl = @@ -178,15 +179,10 @@ function allIncluded() { filterAndStoreData(); } - function filterDataByDate(data){ - var today = new Date(); - var noDays_to_goback = gsoc == 0 ? 7 : 1; - - const localStart = new Date(today.getFullYear(), today.getMonth(), today.getDate() - noDays_to_goback); - localStart.setHours(0, 0, 0, 0); + function filterDataByDate(data, startingDate, endingDate){ - const localEnd = new Date(); - localEnd.setHours(23, 59, 59 ,999); + const localStart = new Date(startingDate + 'T00:00:00Z'); + const localEnd = new Date(endingDate + 'T23:59:59Z'); return data.items.filter(item => { const updatedAt = new Date(item.updated_at); @@ -196,13 +192,13 @@ function allIncluded() { function filterAndStoreData() { if(githubIssuesData) { - githubIssuesData.items = filterDataByDate(githubIssuesData); + githubIssuesData.items = filterDataByDate(githubIssuesData, startingDate, endingDate); } if(githubPrsReviewData) { - githubPrsReviewData.items = filterDataByDate(githubPrsReviewData); + githubPrsReviewData.items = filterDataByDate(githubPrsReviewData, startingDate, endingDate); } if(githubUserData) { - githubUserData.items = filterDataByDate(githubUserData); + githubUserData.items = filterDataByDate(githubUserData, startingDate, endingDate); } }