Skip to content

Commit

Permalink
Corrected the isVotingWithinLastThreeMonths function
Browse files Browse the repository at this point in the history
  • Loading branch information
Nandgopal-R committed Mar 8, 2025
1 parent 7ccb3a2 commit 23af0fc
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions .github/scripts/vote_tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,16 @@ module.exports = async ({ github, context, botCommentURL }) => {
// Check if voting duration is within the last three months
function isVotingWithinLastThreeMonths(voteInfo) {
const currentDate = new Date();
let previousDate;
if (
voteInfo.isVotedInLast3Months ===
"Member has not voted in all previous voting process."
) {
previousDate = new Date(voteInfo.firstVoteClosedTime);
let lastVoteDate;

if (voteInfo.lastParticipatedVoteTime && !voteInfo.lastParticipatedVoteTime.includes("Member has not")) {
lastVoteDate = new Date(voteInfo.lastParticipatedVoteTime);
} else {
previousDate = new Date(voteInfo.lastVoteClosedTime);
return false; // No valid voting history
}
const diffInMs = currentDate - previousDate;
const diffInDays = diffInMs / (1000 * 60 * 60 * 24);

return diffInDays <= 90; // 90 days ≈ 3 months
const diffInDays = (currentDate - lastVoteDate) / (1000 * 60 * 60 * 24);
return diffInDays <= 90; // 90 days = 3 months
}

// Function to update the voteTrackingFile with updated TSC Members
Expand Down Expand Up @@ -329,7 +326,7 @@ module.exports = async ({ github, context, botCommentURL }) => {

if (updatedTSCMembers.length > 0) {
try {
updatedVoteDetails.concat(...updatedTSCMembers);
updatedVoteDetails = updatedVoteDetails.concat(...updatedTSCMembers);
await writeFile(
voteTrackingFile,
JSON.stringify(updatedVoteDetails, null, 2)
Expand Down

0 comments on commit 23af0fc

Please sign in to comment.