Skip to content

Added commits #136

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

Closed
wants to merge 6 commits into from
Closed

Added commits #136

wants to merge 6 commits into from

Conversation

Preeti9764
Copy link
Contributor

@Preeti9764 Preeti9764 commented Jun 17, 2025

Fixes #51


📝 Summary of Changes

The Commits made in existing PRs will be visible in generated Scrum along with the base PR.

📸 Screenshots / Demo (if UI-related)

image

Summary by Sourcery

Add support for retrieving commits from open pull requests and integrate them into the Scrum report, while refactoring the GitHub data pipeline and caching logic, and enhancing UI feedback during report generation.

New Features:

  • Fetch and include individual commits from open PRs within the reporting period into the generated Scrum report.

Bug Fixes:

  • Fix minor formatting inconsistencies in logging statements.

Enhancements:

  • Modularize GitHub data flow into dedicated functions (fetchGithubIssues, fetchCommitsForOpenPRs, processAllData, etc.) for better maintainability.
  • Upgrade caching strategy to persist data in Chrome storage with configurable TTL and automatic refresh on cache key mismatch or expiry.
  • Streamline Scrum content generation by unifying issue, PR review, and commit rendering in a single pass and reduce redundant setInterval loops.
  • Improve UI feedback by showing a loading spinner on the generate button and resetting its state after report generation.

Copy link
Contributor

sourcery-ai bot commented Jun 17, 2025

Reviewer's Guide

This PR extends the Scrum report generator by fetching a user’s commits for open PRs within the selected date range, integrating them into the “What did I do” section, and refactors the data-fetching/processing flow for clarity. It also adds a loading spinner to the Generate Report button and tidies up formatting and indentation.

Sequence diagram for generating Scrum report with commit fetching

sequenceDiagram
    actor User
    participant UI as Popup/Email UI
    participant Button as Generate Report Button
    participant ScrumHelper as scrumHelper.js
    participant GitHub as GitHub API

    User->>Button: Click 'Generate Report'
    Button->>ScrumHelper: Trigger allIncluded('popup')
    ScrumHelper->>ScrumHelper: fetchGithubData()
    ScrumHelper->>GitHub: Fetch issues, PRs, user data
    GitHub-->>ScrumHelper: Return issues, PRs, user data
    ScrumHelper->>GitHub: For each open PR, fetch commits
    GitHub-->>ScrumHelper: Return commits for each PR
    ScrumHelper->>ScrumHelper: Integrate commits into report data
    ScrumHelper->>UI: Update Scrum report content
    ScrumHelper->>Button: Update button state (spinner/refresh)
    UI-->>User: Show updated Scrum report with commits
Loading

Flow diagram for Scrum report data processing with commit integration

flowchart TD
    A[User clicks Generate Report] --> B[fetchGithubData]
    B --> C[fetchGithubIssues]
    C --> D[fetchCommitsForOpenPRs]
    D --> E[processAllData]
    E --> F[processGithubData]
    F --> G[processPrReviews]
    F --> H[Integrate commits into report]
    G --> I[writeScrumBody]
    H --> I
    I --> J[Update UI with Scrum report]
Loading

File-Level Changes

Change Details Files
Added commit fetching and integration into the Scrum report
  • Introduced githubCommitsData and commitsArray to track commits
  • Implemented fetchCommitsForOpenPRs to pull commits for open PRs, filter by author/date
  • Extended processAllData to invoke commit fetching before report generation
  • Appended commitsArray items to the Scrum “What did I do” list
src/scripts/scrumHelper.js
Refactored data fetching and processing pipeline
  • Consolidated fetch logic into fetchGithubIssues, fetchGithubData, processAllData
  • Separated PR review handling into processPrReviews
  • Unified writeScrumBody and writeGithubIssuesPrs for single-pass report building
src/scripts/scrumHelper.js
Updated UI interactions and feedback
  • Added spinner and disabled state to Generate Report button during data load
  • Styled list elements for consistent margins
  • Ensured refresh button rewrites SCRUM correctly on click
src/scripts/scrumHelper.js
General code cleanup and formatting
  • Normalized brace and indent style, removed trailing spaces
  • Aligned console.log calls and error handlers
  • Updated comments for clarity and consistency
src/scripts/scrumHelper.js

Assessment against linked issues

Issue Objective Addressed Explanation

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

@Preeti9764 Preeti9764 changed the title added commits Added commits Jun 17, 2025
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 @Preeti9764 - 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.

@hpdang
Copy link
Member

hpdang commented Jun 18, 2025

@Preeti9764 the commits were not shown for me when I tested. Could you please share a screenshot compared the two generated scrum (before added commits) and (after added commits). Thanks!

@hpdang hpdang requested a review from vedansh-5 June 18, 2025 07:56
@Preeti9764
Copy link
Contributor Author

Preeti9764 commented Jun 18, 2025

@Preeti9764 the commits were not shown for me when I tested. Could you please share a screenshot compared the two generated scrum (before added commits) and (after added commits). Thanks!

Sure, I will add Screenshots. Actually, this pr helps in fetching the commits we made in our existing PRs which are open and which we are working on, to get track of our commit activities in the selected period. Thanks!

@Preeti9764 Preeti9764 requested a review from hpdang June 20, 2025 12:06
@Preeti9764 Preeti9764 self-assigned this Jun 20, 2025
@Preeti9764
Copy link
Contributor Author

@hpdang @vedansh-5, please check the changes i have made once . Thanks!

@vedansh-5
Copy link
Contributor

vedansh-5 commented Jun 21, 2025

image
I observed this [object object] in UI, my guess is it is appearing because of API limit exceeded message logic.
Caching features are no longer working.
This is the master branch:
https://github.com/user-attachments/assets/3196fcf0-a9a8-4cdc-9afe-d6abaa65b629
This is your branch:
https://github.com/user-attachments/assets/1f8d4925-f1ae-4477-bac0-c7b8a93a120d

In your branch fetch calls are being made everytime I generate scrum content, that shouldn't be the case, fetched data should be saved and retrieved from browser local storage as its being saved in master branch.

Also the GitHub API limit exceeded. message does not behave as expected, sometimes even when the scrum is generated the message is shown, currently the message is shown even if one fetch call fails, but in that case if scrum can be generated partially.
All of this is the result of caching feature breaking down in this, once that is fixed we might not see these errors.
image

Thanks!

@Preeti9764
Copy link
Contributor Author

@vedansh-5, I have fixed the bugs you mentioned and implemented a more robust caching mechanism, which should work correctly. Can you please review it once? Thanks!

@Preeti9764
Copy link
Contributor Author

Preeti9764 commented Jun 21, 2025

@hpdang Can you please check once are commits fetched for you correctly ?Thanks!

Copy link
Contributor

@vedansh-5 vedansh-5 left a comment

Choose a reason for hiding this comment

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

@Preeti9764 Thank you for your hardwork and teh improvements in this PR. After reviewing the changes, I wanted to share some feedback and suggestions for further improvement.

  1. Increased Code Complexity:
    The new multi-entry caching mechanism introduces a lot of additional logic for managing separate cache entries for each username and date range. Since our extension is designed for users to generate one report at a time, this complexity doesn’t provide a tangible benefit and makes the codebase harder to maintain and debug.

  2. Risk of Cache Bloat:
    By creating a new cache entry for every unique combination of username and date range, the cache can grow without bounds over time. This could eventually lead to excessive storage usage, which may impact performance or even hit browser storage limits.

  3. User Experience and UI Consistency:
    The UI presents a single cache TTL setting and a single “refresh cache” button, which suggests to users that there is only one cache to manage. The multi-entry cache model can make the cache’s behavior less predictable and potentially confusing for users, as refreshing or changing settings may not always have the expected effect.

  4. Error Handling and Data Validation:
    There is limited error handling for cases where cache entries might be malformed or incomplete. This could lead to subtle bugs or failures in data retrieval.

  5. Missed Opportunity for Batch Queries:
    Earlier, I had suggested using batch queries to optimize our API usage and avoid hitting the GitHub requests-per-hour-per-IP limit. However, this approach hasn’t been implemented in the current PR. Leveraging GitHub GraphQL batch queries would help us stay within rate limits and improve the extension’s efficiency, especially for users with a lot of activity.

  6. Preferred Cache Removal Workflow:
    One important point is that in the old caching mechanism, the cache was being removed whenever the cache time was changed, ensuring that only the relevant data for the current time period was stored. In the new mechanism, even when new data is fetched, previous data for other periods is still stored. The earlier approach is our preferred workflow, as the extension only fetches the report for one time period at an instance, and this keeps the cache clean and relevant.

I have raised another PR #147 to demonstrate how the commits-fetching function can be implemented using the GitHub GraphQL API and batch queries, while retaining the old caching mechanism. I do not want my PR to be merged, it is just to show how this can be achieved efficiently with the current caching approach.

Given these points, I kindly request that we revert to the older, simpler caching mechanism, which is more aligned with our current workflow and UI.
@hpdang @mariobehling please share your views on this approach.

const githubCache = {
caches: {}, // Store multiple cache entries by key
fetching: false,
queue: [],
Copy link
Contributor

Choose a reason for hiding this comment

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

Multiple cache entries, not really needed, bloats the extension storage.

Comment on lines +148 to +151
throw new Error('GitHub API rate limit exceeded. Please try again in a few minutes.');
}
if (!issuesRes.ok || !prRes.ok || !userRes.ok || !allOpenPrsRes.ok) {
throw new Error(`Failed to fetch data from GitHub. Status: ${issuesRes.status}, ${prRes.status}, ${userRes.status}, ${allOpenPrsRes.status}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

These messages can't be closed by clicking the cross icon, also they do not close by themselves after some time.
image

githubCache.fetching = true;

try {
let issueUrl = `https://api.github.com/search/issues?q=author%3A${username}+org%3Afossasia+created%3A${startingDate}..${endingDate}&per_page=100`;
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed a missing entry that should've been here.
Your branch:
image

Master branch:
image

if (editor && editor.body) {
log('Injecting scrum into email body.');
// Use the proper injection method instead of directly setting innerHTML
const success = window.emailClientAdapter.injectContent(
Copy link
Contributor

Choose a reason for hiding this comment

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

Another bug I observed is I can not change the pointer to another message body ( I checked only for google groups).

bodyBugPreeti.mp4

@Preeti9764 Preeti9764 closed this Jun 24, 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.

To show new commits and comments on a existing PR
3 participants