Skip to content

Fixing -closed -label- issue #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scrum_helper
Submodule scrum_helper added at 518de0
140 changes: 70 additions & 70 deletions src/scripts/scrumHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ ${userReason}`;
let pr_arr = githubPrsReviewDataProcessed[repo][pr];
let prText = '';
prText +=
"<a href='" + pr_arr.html_url + "' target='_blank'>#" + pr_arr.number + '</a> (' + pr_arr.title + ') ';
"<a href='" + pr_arr.html_url + "' target='_blank'>#" + pr_arr.number + '</a> (' + pr_arr.title +
if (showOpenLabel && pr_arr.state === 'open') prText += issue_opened_button;
// Do not show closed label for reviewed PRs
prText += '&nbsp;&nbsp;';
Expand Down Expand Up @@ -1056,6 +1056,7 @@ ${userReason}`;
}

for (let i = 0; i < items.length; i++) {

let item = items[i];
let html_url = item.html_url;
let repository_url = item.repository_url;
Expand All @@ -1074,77 +1075,76 @@ ${userReason}`;
const endDate = new Date(endingDate + 'T23:59:59');
const isNewPR = prCreatedDate >= startDate && prCreatedDate <= endDate;

if (!isNewPR) {
const hasCommitsInRange = showCommits && item._allCommits && item._allCommits.length > 0;

if (!hasCommitsInRange) {
continue; //skip these prs - created outside daterange with no commits
} else { }
} else { }
const prAction = isNewPR ? 'Made PR' : 'Existing PR';
if (isDraft) {
li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a>${showOpenLabel ? ' ' + pr_draft_button : ''}</li>`;
} else if (item.state === 'open') {
li = `<li><i>(${project})</i> - ${prAction} (#${number}) - <a href='${html_url}'>${title}</a>${showOpenLabel ? ' ' + pr_open_button : ''}`;
if (showCommits && item._allCommits && item._allCommits.length && !isNewPR) {
log(`[PR DEBUG] Rendering commits for existing PR #${number}:`, item._allCommits);
item._allCommits.forEach(commit => {
li += `<li style=\"list-style: disc; margin: 0 0 0 20px; padding: 0; color: #666;\"><span style=\"color:#2563eb;\">${commit.messageHeadline}</span><span style=\"color:#666; font-size: 11px;\"> (${new Date(commit.committedDate).toLocaleString()})</span></li>`;
});
}
li += `</li>`;
} else if (item.state === 'closed') {
let merged = null;
if ((githubToken || (useMergedStatus && !fallbackToSimple)) && mergedStatusResults) {
let repoParts = repository_url.split('/');
let owner = repoParts[repoParts.length - 2];
let repo = repoParts[repoParts.length - 1];
merged = mergedStatusResults[`${owner}/${repo}#${number}`];
}
if (merged === true) {
li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a>${showOpenLabel ? ' ' + pr_merged_button : ''}</li>`;
} else {
li = `<li><i>(${project})</i> - Made PR (#${number}) - <a href='${html_url}'>${title}</a>${showOpenLabel ? ' ' + pr_closed_button : ''}</li>`;
}
}
lastWeekArray.push(li);
continue; // Prevent issue logic from overwriting PR li
if (item.pull_request) {
const prCreatedDate = new Date(item.created_at);
const startDate = new Date(startingDate);
const endDate = new Date(endingDate + 'T23:59:59');
const isNewPR = prCreatedDate >= startDate && prCreatedDate <= endDate;
if (!isNewPR) {
const hasCommitsInRange = showCommits && item._allCommits && item._allCommits.length > 0;
if (!hasCommitsInRange) {
continue; // Skip PRs created outside the date range with no commits
}
}

const prAction = isNewPR ? 'Made PR' : 'Existing PR';

// 🟤 Draft PR
if (isDraft) {
li = `<li><i>(${project})</i> - ${prAction} (#${number}) - <a href='${html_url}'>${title}</a> ${pr_draft_button}</li>`;

// 🟢 Open PR
} else if (item.state === 'open') {
li = `<li><i>(${project})</i> - ${prAction} (#${number}) - <a href='${html_url}'>${title}</a> ${pr_open_button}`;
if (showCommits && item._allCommits && item._allCommits.length && !isNewPR) {
log(`[PR DEBUG] Rendering commits for existing PR #${number}:`, item._allCommits);
item._allCommits.forEach(commit => {
li += `<li style="list-style: disc; margin: 0 0 0 20px; padding: 0; color: #666;">
<span style="color:#2563eb;">${commit.messageHeadline}</span>
<span style="color:#666; font-size: 11px;"> (${new Date(commit.committedDate).toLocaleString()})</span>
</li>`;
});
}
li += `</li>`;

// 🔴 Closed PR (check if merged or not)
} else if (item.state === 'closed') {
const isMerged = item.merged_at !== null && item.merged_at !== undefined;

if (isMerged) {
// Merged PR: no label shown
li = `<li><i>(${project})</i> - ${prAction} (#${number}) - <a href='${html_url}'>${title}</a></li>`;
} else {
// Only process as issue if not a PR
if (item.state === 'open' && item.body?.toUpperCase().indexOf('YES') > 0) {
let li2 =
'<li><i>(' +
project +
')</i> - Work on Issue(#' +
number +
") - <a href='" +
html_url +
"' target='_blank'>" +
title +
'</a>' + (showOpenLabel ? ' ' + issue_opened_button : '') +
'&nbsp;&nbsp;</li>';
nextWeekArray.push(li2);
}
if (item.state === 'open') {
li = `<li><i>(${project})</i> - Opened Issue(#${number}) - <a href='${html_url}'>${title}</a>${showOpenLabel ? ' ' + issue_opened_button : ''}</li>`;
} else if (item.state === 'closed') {
// Always show closed label for closed issues
li = `<li><i>(${project})</i> - Opened Issue(#${number}) - <a href='${html_url}'>${title}</a>${showOpenLabel ? ' ' + issue_closed_button : ''}</li>`;
} else {
li =
'<li><i>(' +
project +
')</i> - Opened Issue(#' +
number +
") - <a href='" +
html_url +
"' target='_blank'>" +
title +
'</a> </li>';
}
lastWeekArray.push(li);
// Closed but not merged: no label either
li = `<li><i>(${project})</i> - ${prAction} (#${number}) - <a href='${html_url}'>${title}</a></li>`;
}
issuesDataProcessed = true;
}

lastWeekArray.push(li);
continue;

} else {
// 📌 It's an Issue
if (item.state === 'open' && item.body?.toUpperCase().indexOf('YES') > 0) {
let li2 =
`<li><i>(${project})</i> - Work on Issue(#${number}) - <a href='${html_url}' target='_blank'>${title}</a> ${issue_opened_button}</li>`;
nextWeekArray.push(li2);
}

if (item.state === 'open') {
li = `<li><i>(${project})</i> - Opened Issue(#${number}) - <a href='${html_url}'>${title}</a> ${issue_opened_button}</li>`;
} else if (item.state === 'closed') {
li = `<li><i>(${project})</i> - Opened Issue(#${number}) - <a href='${html_url}'>${title}</a> </li>`;
} else {
li = `<li><i>(${project})</i> - Opened Issue(#${number}) - <a href='${html_url}' target='_blank'>${title}</a></li>`;
}

lastWeekArray.push(li);
}
}
issuesDataProcessed = true;
if (outputTarget === 'email') {
triggerScrumGeneration();
}

let intervalBody = setInterval(() => {
Expand Down