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

Conversation

manhuu14
Copy link

@manhuu14 manhuu14 commented Jul 18, 2025

Fixes #178 — Closed label is visible for merged PRs in reviewed section.

Fixed incorrect status labeling in the reviewed PRs section.

Added logic to display only the "open" label for open PRs.

Prevented display of the "closed" label for merged PRs.

Ensured merged PRs are not mislabeled as closed.
📸 Screenshots
before:-
Screenshot From 2025-07-14 19-51-16
after:-
Screenshot From 2025-07-18 22-24-44

Summary by Sourcery

Fix status labeling in reviewed PRs by only displaying open labels for open pull requests and hiding closed labels for merged or closed PRs, and streamline the rendering logic.

Bug Fixes:

  • Hide "closed" label on merged pull requests
  • Only show the "open" label for open pull requests

Enhancements:

  • Refactor pull request rendering into a clear if-else structure and remove redundant code
  • Add debug logging for commit rendering and merged/closed PR handling
  • Simplify date-range filtering logic

Copy link
Contributor

sourcery-ai bot commented Jul 18, 2025

Reviewer's Guide

This PR refactors the ScrumHelper script to correct PR status labeling by removing closed/draft icons from the reviewed section, streamlining the PR processing loop with template literals, and introducing logic to suppress labels for both merged and closed PRs.

Flow diagram for PR status label rendering logic (after fix)

flowchart TD
    A[Start PR rendering] --> B{Is PR a draft?}
    B -- Yes --> C[Show draft label]
    B -- No --> D{Is PR open?}
    D -- Yes --> E[Show open label]
    D -- No --> F{Is PR closed?}
    F -- Yes --> G{Is PR merged?}
    G -- Yes --> H[Show no label]
    G -- No --> I[Show no label]
    F -- No --> J[Show no label]
Loading

File-Level Changes

Change Details Files
Remove incorrect closed/draft icons in reviewed section
  • Commented out legacy closed‐label assignments
  • Replaced one closed‐button branch with draft‐button placeholder
src/scripts/scrumHelper.js
Refactor PR processing loop
  • Flattened nested blocks and hoisted variable declarations
  • Unified date‐range filtering and HTML construction using template literals
  • Replaced manual string concatenation with cleaner continue‐based flow
src/scripts/scrumHelper.js
Suppress labels for merged and closed PRs
  • Detect merged PRs via merged_at and suppress any status icon
  • Log merged vs. closed events instead of rendering labels
src/scripts/scrumHelper.js
Simplify issue handling
  • Removed closed‐label rendering for issues
  • Retained only the open label and work-on-issue logic
src/scripts/scrumHelper.js
Add placeholder scrum_helper file
  • Introduce new empty helper script
b/scrum_helper

Assessment against linked issues

Issue Objective Addressed Explanation
#178 Show 'Merged' label only for actually merged PRs in the reviewed section.
#178 Show 'Closed' label only for confirmed unmerged PRs in the reviewed section.
#178 Refactor status logic to improve clarity and handling of PR review status labeling.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @manhuu14 - I've reviewed your changes - here's some feedback:

  • Consider extracting the large PR/issue rendering loop into smaller helper functions to reduce duplication and make the flow easier to follow.
  • Clean up the leftover commented-out branches (e.g. old closed/draft label logic) to keep the code tidy and avoid confusion.
  • Replace or remove the console.log debug statements in favor of a consistent logging utility or eliminate them once validation is complete.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the large PR/issue rendering loop into smaller helper functions to reduce duplication and make the flow easier to follow.
- Clean up the leftover commented-out branches (e.g. old closed/draft label logic) to keep the code tidy and avoid confusion.
- Replace or remove the console.log debug statements in favor of a consistent logging utility or eliminate them once validation is complete.

## Individual Comments

### Comment 1
<location> `src/scripts/scrumHelper.js:1026` </location>
<code_context>
-                        '&nbsp;&nbsp;</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> ${issue_closed_button}</li>`;
</code_context>

<issue_to_address>
Inconsistent use of target='_blank' in anchor tags.

Please standardize the use of `target='_blank'` for all external links to ensure consistent navigation behavior.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

manhuu14 and others added 4 commits July 18, 2025 22:59
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant