Skip to content

Fix contributions fetch limit#98

Closed
sunithvs wants to merge 1 commit intomainfrom
codex/find-and-fix-important-bug
Closed

Fix contributions fetch limit#98
sunithvs wants to merge 1 commit intomainfrom
codex/find-and-fix-important-bug

Conversation

@sunithvs
Copy link
Owner

Summary

  • adjust sorting and slicing logic when gathering user contributions

Testing

  • python -m py_compile $(git ls-files '*.py')

@vercel
Copy link
Contributor

vercel bot commented May 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
devb-io ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 17, 2025 4:48pm

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @sunithvs, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

Hello! Gemini/gemini-code-assist here, providing a summary of this pull request to help everyone get up to speed quickly.

This pull request, titled "Fix contributions fetch limit", aims to correct the logic used when fetching user contributions. According to the description, the primary goal is to adjust the sorting and slicing logic to ensure the correct number of contributions (specifically, repositories with contributions) are returned.

The changes are focused on the modules/contributions_fetcher.py file, where the code responsible for fetching and processing contributions is located. The patch modifies how the fetched contributions are sorted and limited after being retrieved.

Highlights

  • Fix Contribution Limiting: The pull request fixes an issue where the logic for limiting the number of repositories returned was redundant and potentially incorrect. Previously, the code would sort repositories by contribution count, slice to the top 5, and then immediately slice again to the top 10. This PR removes the unnecessary [:5] slice, ensuring only the top 10 repositories (sorted by contribution count) are kept.
  • Code Cleanup: The patch also includes minor code cleanup by removing a redundant comment and slightly adjusting formatting.

Changelog

  • modules/contributions_fetcher.py
    • Modified the fetch_recent_contributions function to correct the logic for limiting the number of repositories returned.
    • Removed a redundant slicing operation ([:5]) that was applied before the intended [:10] limit.
    • Updated comments to accurately reflect the sorting and limiting logic (sort by contribution count, limit to top 10 repositories).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Data flows in,
Sort and slice, a careful task,
Top ten now remain.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively addresses a logical bug in how user contributions were sorted and limited, ensuring that the top 10 repositories by contribution count are correctly selected. The updated comments also enhance code clarity. I have one suggestion to further refine the implementation for better efficiency and conciseness.

Summary of Findings

  • Efficiency of Sorting and Slicing Contributions: The method for sorting and limiting contributions to the top 10 repositories can be optimized. The current code creates an intermediate dictionary after sorting, then converts its items to a list for slicing. A more efficient approach is to sort the items, slice the list, and then convert directly to a dictionary, reducing overhead.

Merge Readiness

This pull request fixes an important logical bug and improves the clarity of the contribution fetching logic. I've identified one area for improvement regarding the efficiency and conciseness of the sorting and slicing operation, which I've detailed in a review comment with medium severity.

I recommend addressing this suggestion to further enhance the code quality. Therefore, I am requesting changes. As always, further review and approval by other team members are advised before merging. I am not authorized to approve pull requests.

Comment on lines +77 to +82
contributions = dict(
sorted(contributions.items(), key=lambda x: len(x[1]), reverse=True)
)
contributions = {
k: v for k, v in list(contributions.items())[:10]
}

Choose a reason for hiding this comment

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

medium

The current approach for sorting and slicing contributions involves creating an intermediate dictionary after sorting, and then converting its items back to a list for slicing before creating the final dictionary. This can be made more efficient and slightly cleaner.

Consider sorting the contributions.items() once, slicing the resulting list to get the top 10, and then converting this sliced list directly into the final dictionary. This avoids the creation of the intermediate dictionary and the subsequent list(contributions.items()) call.

I've also taken the liberty to rename the lambda variable from x to item for slightly improved readability, which is a common practice in Python (though not strictly a PEP 8 violation for simple lambdas).

This change would improve both performance (by reducing object creation and iteration) and readability.

            sorted_contribution_items = sorted(
                contributions.items(), key=lambda item: len(item[1]), reverse=True
            )
            contributions = dict(sorted_contribution_items[:10])

@sunithvs sunithvs closed this Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant