Skip to content

Conversation

@vedansh-5
Copy link
Member

@vedansh-5 vedansh-5 commented Jun 22, 2025

📌 Fixes

Fixes #51


📝 Summary of Changes

  • Introduces Commit Visibility for Open PRs: This PR adds a new feature to display the last 5 commits for each open Pull Request directly within the generated scrum report. This provides deeper context on recent progress without leaving the report view.
  • GraphQL API Integration: To implement this efficiently, the extension now utilizes the GitHub GraphQL API. This allows for batching requests for commit data across multiple PRs into a single, performant network call, significantly reducing the number of API requests compared to using the REST API alone.
  • New "Show Commits" Setting:
    • A checkbox, "Show last 5 commits in Open PRs," has been added to the Settings section.
    • This feature is disabled by default.
    • Crucially, it only functions when a GitHub Personal Access Token is provided. This is a strategic choice to encourage users to adopt tokens, as they unlock higher API rate limits and better performance for the entire extension. By linking this valuable feature to token usage, we provide a clear incentive for users to enhance their experience.

📸 Screenshots / Demo (if UI-related)

image


✅ Checklist

  • I’ve tested my changes locally
  • I’ve added tests (if applicable)
  • I’ve updated documentation (if applicable)
  • My code follows the project’s code style guidelines

👀 Reviewer Notes

The core of this feature is the new fetchCommitsForOpenPRs function which constructs and executes a single GraphQL query for all open PRs. The decision to make this a token-only feature is intentional. It acts as a "hook" to encourage users to add a token, which benefits both the user (better performance, higher rate limits) and the extension's stability by reducing unauthenticated API calls.
This Pull Request serves as a technical demonstration to show that the "Show Commits" feature can be successfully implemented on top of our existing caching mechanism. The primary goal is to prove the concept without altering the current cache logic.
This PR is not intended to be merged. It is for review and discussion purposes only.

Summary by Sourcery

Use GraphQL to batch fetch the latest commits for open PRs, attach them to the PR data, and display commit details in the scrum summary to reduce REST API usage.

New Features:

  • Add fetchCommitsForOpenPRs function to retrieve the last commits of open PRs via the GitHub GraphQL API
  • Attach fetched commits to PR objects and render commit headlines, authors, and timestamps as nested lists under open PR entries

Enhancements:

  • Invoke writeGithubIssuesPrs and writeGithubPrsReviews in cache verification to persist updated data

Signed-off-by: Vedansh Saini <[email protected]>
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jun 22, 2025

Reviewer's Guide

This PR introduces a GraphQL‐based batch mechanism to fetch the last commits for all open PRs, integrates that data into each PR object, updates the HTML generation to display those commits inline, and ensures the GitHub data cache is written out properly.

Sequence diagram for fetching and displaying last commits for open PRs using GraphQL

sequenceDiagram
    participant User
    participant scrumHelper
    participant GitHubGraphQLAPI
    User->>scrumHelper: Request PR data
    scrumHelper->>GitHubGraphQLAPI: Batch GraphQL query for last commits of open PRs
    GitHubGraphQLAPI-->>scrumHelper: Return commit data for each PR
    scrumHelper->>scrumHelper: Attach commits to PR objects
    scrumHelper->>User: Render PR list with last commits inline
Loading

Class diagram for PR object with attached last commits

classDiagram
    class PullRequest {
        number: int
        state: string
        title: string
        html_url: string
        repository_url: string
        _lastCommits: Commit[]
    }
    class Commit {
        messageHeadline: string
        committedDate: string
        url: string
        author: Author
    }
    class Author {
        name: string
        user: User
    }
    class User {
        login: string
    }
    PullRequest "*" -- "*" Commit : has
    Commit "1" -- "1" Author : by
    Author "0..1" -- "1" User : may reference
Loading

Flow diagram for batch fetching and displaying PR commits

flowchart TD
    A[Collect open PRs] --> B[Batch fetch last commits via GraphQL]
    B --> C[Attach commits to PR objects]
    C --> D[Generate HTML for PRs]
    D --> E[Display PRs with last commits inline]
Loading

File-Level Changes

Change Details Files
Add GraphQL helper for batch commit retrieval
  • Define async function fetchCommitsForOpenPRs(prs, githubToken)
  • Build a multi‐field GraphQL query string for each PR
  • POST to GitHub’s /graphql endpoint with bearer token
  • Parse JSON response into a map of PR number → commit list
src/scripts/scrumHelper.js
Integrate commit fetching into main data flow
  • After loading issues, filter items for open PRs
  • If token present, call fetchCommitsForOpenPRs with openPRs
  • Attach resulting commits to each pr._lastCommits
src/scripts/scrumHelper.js
Render last commits in the HTML output
  • In the open‐PR
  • , check for item._lastCommits
  • Insert a nested
      listing each commit with link, author, date
    • Close the list block correctly
src/scripts/scrumHelper.js
Ensure cache writes include updated data
  • In verifyCacheStatus(), add writeGithubIssuesPrs()
  • Add writeGithubPrsReviews() after cache verification
src/scripts/scrumHelper.js

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 @vedansh-5 - I've reviewed your changes and they look great!


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.

Signed-off-by: Vedansh Saini <[email protected]>
Signed-off-by: Vedansh Saini <[email protected]>
Signed-off-by: Vedansh Saini <[email protected]>
Signed-off-by: Vedansh Saini <[email protected]>
@Preeti9764
Copy link
Contributor

Preeti9764 commented Jun 23, 2025

@vedansh-5 .

  1. I don't think someone wants this like to add the last 5 commits, either we should have this functionality or not, but giving partial commit info to the user is not preferable.
    image
  2. even after selecting box which you added to settings i am unable to see the commits .

image
3.The commits section should be different not below the prs and we need to see the pr we made ,just like seperate reviewed pr section.
4. I am unable to generate report without the github token.As earlier our extension is made to use without github tokens , which is what need to be maintained and additional feature of tokens used with it for betterment but without affecting the core , which is it need to response without tokens too.

image

@hpdang Please share your views.

@vedansh-5
Copy link
Member Author

  1. I don't think someone wants this like to add the last 5 commits, either we should have this functionality or not, but giving partial commit info to the user is not preferable.

Thanks for your review, as mentioned this is PR is just a demonstration of the feature and isn't intended to be merged, it actually is better to show last 5 commits, if someone is working on a PR for days they would have a long list of commits, and we would only want to show the latest ones as previous ones would be there in previous reports, despite this thinking, this behavior can be changed to fetch all commits in a single fetch request for upto 50 open PRs.

@vedansh-5
Copy link
Member Author

vedansh-5 commented Jun 23, 2025

The commits section should be different not below the prs and we need to see the pr we made ,just like seperate reviewed pr section.

Again it makes more sense to put the commits next to open PRs, this is formatting not related to core functionality of the feature. My approach is more user friendly and makes more sense rather than showing the PRs once and then listing them again for commits.
Your branch:
Uploading image.png…

@vedansh-5
Copy link
Member Author

I am unable to generate report without the github token.As earlier our extension is made to use without github tokens , which is what need to be maintained and additional feature of tokens used with it for betterment but without affecting the core , which is it need to response without tokens too.

The image you have added prompts the message invalid github or expired github token, which means your token is incorrect.
The extension still makes public requests without the github token, this happens when there is no token in the input field, thus maintaining the core functionality of our extension.

@vedansh-5
Copy link
Member Author

2. even after selecting box which you added to settings i am unable to see the commits .

One known vulnerability is that, when users make a public fetch request(without github token) then the commits data is not fetched, and later on when they put github token and checks the last 5 commits checkbox for the same time the report is generated from cache(which does not generate commits data), this can be the issue you're facing, otherwise the feature works fine, and this vulnerability can be solved very easily, I noticed it just before I was going to bed so haven't worked on it.

@vedansh-5
Copy link
Member Author

Thanks for your reviews @Preeti9764 this PR is just a demonstration that this feature can be achieved efficiently with the current caching mechanism, I do not want to refine this PR as I do not want it to be merged.
@hpdang @mariobehling Please share your views on this.

@Preeti9764
Copy link
Contributor

I am unable to generate report without the github token.As earlier our extension is made to use without github tokens , which is what need to be maintained and additional feature of tokens used with it for betterment but without affecting the core , which is it need to response without tokens too.

The image you have added prompts the message invalid github or expired github token, which means your token is incorrect. The extension still makes public requests without the github token, this happens when there is no token in the input field, thus maintaining the core functionality of our extension.

I have not added the github token, and it was the image of that time, also i trying to say that if we did not use the github tokens this commit functionality will not work, as tokens are additional we cannot create commits adding just for tokens users.Thanks!

@Preeti9764
Copy link
Contributor

Thanks for your reviews @Preeti9764 this PR is just a demonstration that this feature can be achieved efficiently with the current caching mechanism, I do not want to refine this PR as I do not want it to be merged. @hpdang @mariobehling Please share your views on this.

I got the changes you have made here and but they limit the functionality of commit fetching , I have also thought of that but i did do that in my pr cause i don't want this kind of challenges for the users and want to keep things simpler for them and also enhanced the caching for same reasons. I known your concern of the code change as i addressed the issue you put personally , I will also do same here also. I have just implemented new changes so that we can have it , that can be refined according to your guidance @hpdang .Thanks for suggesting this!

@vedansh-5 vedansh-5 self-assigned this Jun 25, 2025
@vedansh-5
Copy link
Member Author

In the latest changes I have fixed this vulnerability,
One known vulnerability is that, when users make a public fetch request(without github token) then the commits data is not fetched, and later on when they put github token and checks the last 5 commits checkbox for the same time the report is generated from cache(which does not generate commits data), this can be the issue you're facing, otherwise the feature works fine, and this vulnerability can be solved very easily, I noticed it just before I was going to bed so haven't worked on it.
I will rebase this PR and soon add the functionalityto take user input for the number of commits.

@vedansh-5 vedansh-5 force-pushed the commits branch 2 times, most recently from de3b202 to 9b1dfcb Compare June 25, 2025 17:43
Signed-off-by: Vedansh Saini <[email protected]>
@vedansh-5
Copy link
Member Author

@Preeti9764 @hpdang Please take a look whenever you can, thank you.

@Preeti9764
Copy link
Contributor

image
These prs are not close they are merged , can we only have open label for reviewed prs as like the current behaviour as this can cause confusion @hpdang share your views .Thanks!

@Preeti9764
Copy link
Contributor

image
@vedansh-5 it is showing wrong dates for custom date input .Could you please clearify a little about this .Thanks!

@vedansh-5
Copy link
Member Author

it is showing wrong dates for custom date input .Could you please clearify a little about this .Thanks!

Hey @Preeti9764 , this is the old bug as we knew it, since it has already been solved in the master and no conflicts arises for the feature branch this issue will be solved when this PR is merged. thank you

@vedansh-5
Copy link
Member Author

Anyways, these were small changes so I did them again in this PR, could you please check it again?
image

Signed-off-by: Vedansh Saini <[email protected]>
@Preeti9764
Copy link
Contributor

@vedansh-5 I have checked it ,the report is correctly generated in the scrum preview but it sometimes not visible in google groups, gmail ..please look into this .Thanks!
image
Screenshot 2025-07-02 095126
Screenshot 2025-07-02 095245

@vedansh-5
Copy link
Member Author

@vedansh-5 I have checked it ,the report is correctly generated in the scrum preview but it sometimes not visible in google groups, gmail ..please look into this .Thanks! image Screenshot 2025-07-02 095126 Screenshot 2025-07-02 095245

Could you please clarify as to when this behavior is seen under what usecase or parameters set, because I cannot replicate the issue. Thankyou.

Signed-off-by: Vedansh Saini <[email protected]>
@vedansh-5
Copy link
Member Author

Please check if the issue persists, i added a dateBug handler.
@Preeti9764

@hpdang
Copy link
Member

hpdang commented Jul 3, 2025

@Preeti9764 please test this

@Preeti9764
Copy link
Contributor

Preeti9764 commented Jul 3, 2025

I am experiencing some anonymous issues.Sometimes it fetches correctly but some time it shows like this , sometime in first refresh or maybe after 2,3 refersh , then have to refresh again . I starts showing just reviewed prs.

2025-07-02.22-22-46.mp4

@hpdang
Copy link
Member

hpdang commented Jul 3, 2025

@vedansh-5 @Preeti9764 I was thinking about this, is it possible to show commits only on the existing PRs and not on those made PRs? The reason people want to show commits because they haven't managed to close their existing PRs and want to make the progress visible. I don't think it is necessary to show commits on newly created/made PRs. What do you think about this idea?

@vedansh-5
Copy link
Member Author

@vedansh-5 @Preeti9764 I was thinking about this, is it possible to show commits only on the existing PRs and not on those made PRs? The reason people want to show commits because they haven't managed to close their existing PRs and want to make the progress visible. I don't think it is necessary to show commits on newly created/made PRs. What do you think about this idea?

Yes makes sense, I will make the changes for this.

vedansh-5 added 2 commits July 3, 2025 14:50
Signed-off-by: Vedansh Saini <[email protected]>
Signed-off-by: Vedansh Saini <[email protected]>
@vedansh-5
Copy link
Member Author

Now the extension only show commits in the existing Prs and not in made Prs,
image

Also I have fixed a race condition that was already fixed in master, but not in this feature branch. I have tested with all email clients with multiple refreshes, I did not encounter the problem.
@hpdang @Preeti9764 Please check whether it works for you.
This PR is ready to be merged from my side. thankyou

@Preeti9764
Copy link
Contributor

@hpdang @vedansh-5 can we have commits for draft prs too, for showing the progress in the draft PR.

@vedansh-5
Copy link
Member Author

vedansh-5 commented Jul 3, 2025

@hpdang @vedansh-5 can we have commits for draft prs too, for showing the progress in the draft PR.

Good point, I had thought about that too and even worked on it for a bit, but decided it’s cleaner to handle draft PR commits in a separate PR. So I reverted that part here to keep this focused. let’s get this merged, and I’ll pick up the draft PR progress in a follow-up. thankyou.
Does it work fine for you now? @Preeti9764

@Preeti9764
Copy link
Contributor

@vedansh-5 Please remove the unnecessary file scrumHelperdummy.js, which you have pushed .Thanks!

I had added this file during a rebase, incase things went south, forgot to remove it. Thanks @Preeti9764
@hpdang
Copy link
Member

hpdang commented Jul 4, 2025

@Preeti9764 is it good now to merge?

@hpdang hpdang merged commit b1d37bc into fossasia:master Jul 4, 2025
@vedansh-5 vedansh-5 deleted the commits branch August 1, 2025 13:22
@vedansh-5 vedansh-5 changed the title using graphQL for commit fetching solving the api exemption issue. Minor: using graphQL for commit fetching solving the api exemption issue. Aug 4, 2025
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.

To show new commits and comments on a existing PR

3 participants