Skip to content

Enhance PR section with type badges, state, merged status, and merged…#163

Merged
mehul-m-prajapati merged 1 commit intoGitMetricsLab:mainfrom
gargivermaa:enhance-pr-gargi-clean
Aug 1, 2025
Merged

Enhance PR section with type badges, state, merged status, and merged…#163
mehul-m-prajapati merged 1 commit intoGitMetricsLab:mainfrom
gargivermaa:enhance-pr-gargi-clean

Conversation

@gargivermaa
Copy link
Contributor

@gargivermaa gargivermaa commented Jul 31, 2025

📅 Date
July 31, 2025

🔗 Related Issue
Closes: #28

✨ Description
This PR enhances the Pull Request (PR) section of the GitHub Tracker dashboard by:

Adding design labels and metrics for each PR

Displaying PR type, state (open/closed/merged), merged status, and merged date

Using Tailwind CSS badges for clean and informative UI presentation

Improving overall visualization of contributor activity

✅ How Has This Been Tested?
Tested locally on latest codebase using mock GitHub data

Verified UI changes in the PR section of the Home page

Ensured proper display of badges and values across PRs in multiple states

📸 Screenshots (if applicable)
Screenshot 2025-07-31 163428

📦 Type of Change
New feature

Code style update

Summary by CodeRabbit

  • New Features
    • Added a "Type" column to the issues and pull requests table, displaying categorized badges for each pull request based on its title.
    • When viewing pull requests, new "Merged" and "Merged Date" columns show whether a pull request was merged and the corresponding date.

@netlify
Copy link

netlify bot commented Jul 31, 2025

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit 0a24f94
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/688b8b95ab57560008627d90
😎 Deploy Preview https://deploy-preview-163--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 31, 2025

Walkthrough

A new feature is introduced to categorize pull requests by type using keywords in their titles. Two helper functions determine the PR type and corresponding badge style. The dashboard table now includes a "Type" column with styled badges, and, for pull requests, "Merged" and "Merged Date" columns are conditionally displayed.

Changes

Cohort / File(s) Change Summary
PR Type Categorization & Badge Styling
src/pages/Home/Home.tsx
Added getPRType and getBadgeStyle helper functions; updated table to display PR type badges, and, for PRs, merged status and merged date columns.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HomePage
    participant HelperFunctions

    User->>HomePage: View dashboard
    HomePage->>HelperFunctions: getPRType(title)
    HelperFunctions-->>HomePage: Return PR type
    HomePage->>HelperFunctions: getBadgeStyle(type)
    HelperFunctions-->>HomePage: Return badge style classes
    HomePage->>User: Render table with Type badge, Merged, and Merged Date columns
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Add proper design labels for PRs in dashboard (#28)
Add Tailwind CSS styling for PR/issue type/status badges (#28)
Display PR type and merged status/merged date in dashboard (#28)

Suggested labels

gssoc25, level2

Poem

In the dashboard fields where pull requests roam,
Now badges bloom—each with a colored home.
"Feature" or "Fix," their labels shine bright,
With merged dates and status in clear sight.
A rabbit hops by, giving a cheer:
"Well done, team—your code is crystal clear!"
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/pages/Home/Home.tsx (1)

28-37: Improve keyword matching logic and add input validation.

The current implementation has potential issues:

  1. No input validation for null/undefined values
  2. Order-dependent matching could lead to unexpected results (e.g., "fix feature bug" returns "Fix" instead of "Feature")
  3. Simple substring matching may cause false positives

Consider this improved implementation:

-function getPRType(title: string): string {
-  const lower = title.toLowerCase();
-  if (lower.includes("feature")) return "Feature";
-  if (lower.includes("fix")) return "Fix";
-  if (lower.includes("cleanup") || lower.includes("refactor")) return "Cleanup";
-  if (lower.includes("docs")) return "Docs";
-  if (lower.includes("test")) return "Test";
-  return "Other";
-}
+function getPRType(title: string): string {
+  if (!title?.trim()) return "Other";
+  
+  const lower = title.toLowerCase();
+  
+  // Use word boundaries or more specific patterns to avoid false positives
+  const patterns = [
+    { keywords: ['feat:', 'feature'], type: 'Feature' },
+    { keywords: ['fix:', 'bug:', 'hotfix'], type: 'Fix' },
+    { keywords: ['docs:', 'documentation'], type: 'Docs' },
+    { keywords: ['test:', 'testing'], type: 'Test' },
+    { keywords: ['refactor:', 'cleanup:', 'clean'], type: 'Cleanup' },
+  ];
+  
+  for (const pattern of patterns) {
+    if (pattern.keywords.some(keyword => lower.includes(keyword))) {
+      return pattern.type;
+    }
+  }
+  
+  return "Other";
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9fa26a8 and 0a24f94.

📒 Files selected for processing (1)
  • src/pages/Home/Home.tsx (4 hunks)
🔇 Additional comments (3)
src/pages/Home/Home.tsx (3)

39-55: LGTM! Well-structured badge styling function.

The color mapping is intuitive and follows common conventions (green for features, red for fixes, etc.). The switch statement structure is clean and the default case properly handles unknown types.


293-296: LGTM! Table header structure is well-organized.

The new "Type" column and conditional PR-specific columns are properly positioned and the conditional rendering logic is correct.


330-341: LGTM! Conditional PR columns are well-implemented.

The conditional rendering logic is consistent with the table headers, proper null safety is maintained with optional chaining, and appropriate fallback values are provided.

Comment on lines +321 to +326
{/* 🆕 PR Type Label */}
<TableCell>
<span className={`px-2 py-1 rounded-full text-xs font-semibold ${getBadgeStyle(getPRType(item.title))}`}>
{getPRType(item.title)}
</span>
</TableCell>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider semantic correctness for issue categorization.

The badge is applied to both issues and PRs, but getPRType suggests it's specifically for pull requests. Issues may not follow the same naming conventions, potentially leading to incorrect categorization.

Consider renaming the function or creating separate logic:

-                    {/* 🆕 PR Type Label */}
+                    {/* 🆕 Type Label */}
                     <TableCell>
-                      <span className={`px-2 py-1 rounded-full text-xs font-semibold ${getBadgeStyle(getPRType(item.title))}`}>
-                        {getPRType(item.title)}
+                      <span className={`px-2 py-1 rounded-full text-xs font-semibold ${getBadgeStyle(getItemType(item.title))}`}>
+                        {getItemType(item.title)}
                       </span>
                     </TableCell>

And rename the helper function:

-function getPRType(title: string): string {
+function getItemType(title: string): string {

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/pages/Home/Home.tsx around lines 321 to 326, the function getPRType is
used to categorize both issues and pull requests, which may cause incorrect
labeling since issues might not follow PR naming conventions. Rename getPRType
to a more generic name like getIssueOrPRType or create separate functions for
issues and PRs to handle their categorization correctly. Update all references
accordingly to ensure semantic correctness in badge labeling.

@mehul-m-prajapati mehul-m-prajapati merged commit d2d4619 into GitMetricsLab:main Aug 1, 2025
7 checks passed
@github-actions
Copy link

github-actions bot commented Aug 1, 2025

🎉🎉 Thank you for your contribution! Your PR #163 has been merged! 🎉🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 Feature: Add proper design labels for the PRs in dashboard

2 participants