Skip to content

New Contributor and Top PR listing section Fixes #235#236

Merged
A1L13N merged 6 commits into
alphaonelabs:mainfrom
bits-and-atoms:prranking
Mar 23, 2025
Merged

New Contributor and Top PR listing section Fixes #235#236
A1L13N merged 6 commits into
alphaonelabs:mainfrom
bits-and-atoms:prranking

Conversation

@bits-and-atoms
Copy link
Copy Markdown
Contributor

@bits-and-atoms bits-and-atoms commented Mar 23, 2025

Fixes #235
Screenshot 2025-03-23 at 1 42 45 PM
Screenshot 2025-03-23 at 1 42 51 PM

Summary by CodeRabbit

  • New Features
    • Replaced the "Recent Contributors" section with a comprehensive "GitHub Contributors Section" featuring three columns: "Top Contributors," "New Contributors," and "Recent Contributions."
    • The "Top Contributors" column displays the highest contributors with avatars, usernames, merged PR counts, and ranking badges.
    • The "New Contributors" column highlights first-time contributors with their avatars, usernames, PR details, and badges for recent joiners.
    • The "Recent Contributions" column lists the latest pull requests with contributor details and statuses.
    • Added error handling for data-fetching to manage API failures and display appropriate messages.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 23, 2025

Walkthrough

This change introduces a new structure for displaying GitHub contributors in the main HTML template. The previous "Recent Contributors" section is replaced with a comprehensive "GitHub Contributors Section," which includes three columns: "Top Contributors," "New Contributors," and "Recent Contributions." Each column fetches data from the GitHub API, processes it to display relevant contributor information, and includes error handling for API failures.

Changes

File Change Summary
web/templates/index.html Replaced "Recent Contributors" with "GitHub Contributors Section" containing three columns: "Top Contributors" (fetching contributors with highest merged PRs), "New Contributors" (showing those with one merged PR), and "Recent Contributions" (listing recent PRs).

Assessment against linked issues

Objective Addressed Explanation
New Contributors and Top PRs section (#235)

Possibly related PRs

Suggested labels

d:21, d:22

Suggested reviewers

  • A1L13N

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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
Copy Markdown
Contributor

@A1L13N A1L13N left a comment

Choose a reason for hiding this comment

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

can you please make it so that it's all the way at the bottom and on the left is top contributors, then New Contributors, then Recent Contributors and so it spans the whole page and make it 10 users for each and please make sure it links to their GitHub showing the relevant info
image

Copy link
Copy Markdown
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: 0

🧹 Nitpick comments (2)
web/templates/index.html (2)

816-962: New Contributors Section: Robustness & Readability Improvements

The markup and logic for the "New Contributors" section is well-structured and accomplishes the goal of fetching, filtering, and rendering contributors with exactly one merged PR. A few observations and suggestions:

  • Data Consistency: The code uses contributor.created_at when displaying the first PR date. Verify that the intended date (e.g. PR creation vs. merge date) is consistently used, as the filtering logic is based on merged_at.
  • Error Handling & Rate Limiting: The current error handling in the .catch block is good. However, since the GitHub API might enforce rate limits, you might want to log or display a clear message if the rate limit is exceeded.
  • Readability & Modernization: Consider refactoring the nested promise chains into an async/await structure. This could improve readability and error handling.

Overall, the implementation is functional and meets the PR objectives.


963-1105: Top Contributors Section: Clear Logic with Room for Refactor

The "Top Contributors" section implements an effective strategy to aggregate merged PR counts, sort contributors based on the number of merged PRs and most recent merge dates, and display ranking badges. A few points to consider:

  • API Endpoint & Filtering: The script correctly filters out non-merged or bot-generated PRs, ensuring only valid data is processed. Confirm that the use of the closed state and subsequent filtering with if (!pull.merged_at) return; consistently yields the expected merged PR data.
  • Consistency and Code Duplication: The overall structure is similar to the "New Contributors" section. In the future, if both sections grow further, consider refactoring common logic (e.g., API data fetching and error handling) into a shared utility function.
  • Async/Await Suggestion: As with the previous section, using async/await would improve readability, simplify error handling, and reduce the nesting of promise chains.

Overall, the code meets the PR objectives effectively and is well-organized.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1ec6ec6 and 015c8a5.

📒 Files selected for processing (1)
  • web/templates/index.html (1 hunks)

coderabbitai[bot]
coderabbitai Bot previously approved these changes Mar 23, 2025
@A1L13N
Copy link
Copy Markdown
Contributor

A1L13N commented Mar 23, 2025

Can you show the screenshot please?

Copy link
Copy Markdown
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: 0

🧹 Nitpick comments (4)
web/templates/index.html (4)

746-829: New GitHub Contributors Section Added
The new HTML section clearly introduces a dedicated "GitHub Contributors" area with three columns for Top Contributors, New Contributors, and Recent Contributions. The use of Tailwind CSS classes (e.g., grid layouts, responsive spacing, and loading skeletons via animate-pulse) creates a modern and user-friendly interface. One suggestion is to ensure that external links (such as those for "View All Contributors on GitHub" and "How to Contribute") include the attributes rel="noopener noreferrer" along with target="_blank" for improved security and performance.


830-938: Robust API Data Fetching for Top Contributors
The fetchTopContributors function is well-structured—it fetches pull request data, correctly filters out bot accounts, and orders contributors based on the number of merged PRs and recency of contributions. The sorting logic is sound, and the use of dynamic HTML creation to populate the section is effective.
However, to improve error handling, consider validating the HTTP response before calling response.json(). For example, you might add:

- fetch('https://api.github.com/repos/AlphaOneLabs/education-website/pulls?state=closed&per_page=100')
-    .then(response => response.json())
+ fetch('https://api.github.com/repos/AlphaOneLabs/education-website/pulls?state=closed&per_page=100')
+    .then(response => {
+         if (!response.ok) {
+            throw new Error('Network response was not ok: ' + response.statusText);
+         }
+         return response.json();
+    })

This change would catch API errors earlier and provide more robust feedback via the catch block.


939-1037: Optimize Fetch Function for New Contributors
In the fetchNewContributors function, the variable prCounts is initialized and incremented but never used in subsequent logic. Removing this redundant code would simplify the function and improve readability.

For example, you could remove:

-                    const prCounts = {};
-                    if (!prCounts[username]) {
-                        prCounts[username] = 1;
-                    } else {
-                        prCounts[username]++;
-                    }

Also, as with the top contributors function, consider checking response.ok before parsing the JSON response to improve error handling.


1038-1096: Reviewing Recent Contributions Fetch Logic
The fetchRecentContributions function efficiently filters the most recent pull requests and builds the UI dynamically. The conditional rendering of the status badge based on the pull request state is effective for conveying real-time status.
Again, for consistency and robustness, adding a check for response.ok before invoking response.json() is recommended. Verify that slicing to ten items meets your design expectations when fewer or more PRs are returned.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 015c8a5 and 672c95a.

📒 Files selected for processing (1)
  • web/templates/index.html (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Run Tests
🔇 Additional comments (1)
web/templates/index.html (1)

1097-1101: DOMContentLoaded Event Listener
The event listener hooked to DOMContentLoaded ensures that all three data-fetching functions are invoked after the document is fully loaded. This is a clean approach to asynchronously populate the GitHub data without delaying the initial page render.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Mar 23, 2025
@bits-and-atoms
Copy link
Copy Markdown
Contributor Author

Screenshot 2025-03-23 at 2 51 15 PM Screenshot 2025-03-23 at 2 51 02 PM

@bits-and-atoms bits-and-atoms requested a review from A1L13N March 23, 2025 09:49
@A1L13N
Copy link
Copy Markdown
Contributor

A1L13N commented Mar 23, 2025

image
Can you please move the numbers to be small badges on the avatars, add more recent contributors and limit the recent contributions to only merged? It looks great!

A1L13N
A1L13N previously requested changes Mar 23, 2025
Copy link
Copy Markdown
Contributor

@A1L13N A1L13N left a comment

Choose a reason for hiding this comment

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

See photo

Copy link
Copy Markdown
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: 0

🧹 Nitpick comments (4)
web/templates/index.html (4)

746-748: New GitHub Contributors Section Integration
The new section is cleanly injected into the template with a clear demarcation from previous content. Please verify that the closing tags and container structures align with the overall page layout and maintain responsive behavior across different devices.


832-965: Efficient Contributor Aggregation in fetchTopContributors
The implementation correctly fetches closed pull requests, filters out bots, and only processes merged pull requests. The aggregation logic—updating merged counts, tracking the latest merged dates, and dynamically assigning rank badges—is robust and clear. One potential improvement is to consider caching or sharing the API response with other similar functions to reduce duplicate network calls (see later comments).


968-1082: Logical Extraction of New Contributors
This function effectively groups PRs by user, sorts them by the merged date to identify the earliest merged contribution, and marks users as “new” if their first merged PR was within the last 30 days. The logic is sound; however, note that the same GitHub API endpoint is used in multiple functions. Consolidating these API calls could improve overall performance and simplify maintenance.


830-1150: Optimization and DRY Considerations for API Fetching
Multiple functions (fetchNewContributors and fetchRecentContributions) request similar data from the GitHub API using nearly identical query parameters. Consider abstracting the API call into a shared helper function or caching the pull request data once—then reusing it across functions—to reduce redundant network requests and mitigate potential rate limiting issues.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 672c95a and 804e42e.

📒 Files selected for processing (1)
  • web/templates/index.html (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Run Tests
🔇 Additional comments (3)
web/templates/index.html (3)

749-829: Structured Layout for Contributor Displays
The three-column layout separating “Top Contributors,” “New Contributors,” and “Recent Contributions” is well organized. The use of semantic HTML and utility classes (e.g., for spacing and background colors) supports a clear and consistent design. The inclusion of placeholders with an “animate-pulse” effect improves the user experience while data is loading.


1084-1142: Clear Display of Recent Contributions
The function filters PRs to include only non-bot, merged contributions, then sorts and slices the top 10 most recent entries. The resulting HTML injection with contributor avatars, titles, and merged dates is clear and user-friendly. Error handling and fallback messaging further enhance the user experience.


1144-1149: DOMContentLoaded Listener Setup
The script’s use of the DOMContentLoaded event to trigger the three fetch functions ensures that data fetching occurs only after the HTML is fully loaded. This is a sound approach to prevent rendering race conditions with dynamic content.

@bits-and-atoms bits-and-atoms requested a review from A1L13N March 23, 2025 13:22
@bits-and-atoms
Copy link
Copy Markdown
Contributor Author

Screenshot 2025-03-23 at 6 28 08 PM

@A1L13N A1L13N enabled auto-merge (squash) March 23, 2025 17:10
@A1L13N A1L13N merged commit 66cbfb5 into alphaonelabs:main Mar 23, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Apr 5, 2025
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.

New Contributors and Top PRs section

2 participants