Skip to content

Revert "To show Commits in Scrum Report " #131

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

Merged
merged 1 commit into from
Jun 16, 2025
Merged

Conversation

hpdang
Copy link
Member

@hpdang hpdang commented Jun 16, 2025

Reverts #114

Standalone generation is not working. Username and other inputs are not being saved.

Summary by Sourcery

Revert previous commit–showing enhancements and restore basic Scrum report generation, fixing broken standalone workflow and input persistence.

Bug Fixes:

  • Ensure standalone report generation works by removing incomplete storage and caching logic

Enhancements:

  • Simplify GitHub data retrieval to straightforward AJAX calls and drop complex commit-fetching and batch processing

Documentation:

  • Remove outdated “New Features” section from README

Chores:

  • Clean up JavaScript style by converting let/const to var, remove debug utilities, force-refresh button, and adjust CSS/HTML formatting

Copy link
Contributor

sourcery-ai bot commented Jun 16, 2025

Reviewer's Guide

This PR reverts the previous commit that added detailed commit-level fetching and caching by removing complex batch and storage logic, restoring simple jQuery AJAX calls for GitHub issues, PR reviews, and user data, cleaning up debug utilities and variable declarations, and simplifying the report injection and refresh mechanisms.

Class diagram for reverted caching and commit-fetching logic

classDiagram
    class ScrumHelper {
        +allIncluded(outputTarget)
        +fetchGithubData()
        +writeGithubIssuesPrs()
        +writeGithubPrsReviews()
        +writeScrumBody()
        +scrumSubjectLoaded()
    }

    %% The following classes and objects were removed in the revert:
    class GithubCache {
        -data
        -cacheKey
        -timestamp
        -ttl
        -fetching
        -queue
        -errors
        -errorTTL
        -subject
        +saveToStorage()
        +loadFromStorage()
        +forceGithubDataRefresh()
        +verifyCacheStatus()
        +debugCache()
    }
    ScrumHelper ..|> GithubCache : (Removed composition)

    %% The reverted code no longer uses GithubCache, and fetchGithubData is now a simple AJAX function.
Loading

File-Level Changes

Change Details Files
Removed commit-based caching and batch processing logic
  • Deleted githubCache object, save/load storage functions, and batch commit fetch routines
  • Replaced complex fetchGithubData with separate jQuery.ajax calls for issues, PR reviews, and user data
  • Removed commit pagination and retry handlers
src/scripts/scrumHelper.js
Simplified variable declarations and logging
  • Replaced let/const with var declarations throughout
  • Removed DEBUG flag and custom log/logError functions
  • Condensed console.log statements
src/scripts/scrumHelper.js
src/scripts/main.js
Streamlined Scrum report injection and refresh logic
  • Removed hasInjectedContent flag, refreshButton and forceRefresh handler
  • Merged separate intervals for issues and PRs into a single interval that triggers write functions when data is ready
  • Simplified writeScrumBody condition checks and eliminated nested timeouts
src/scripts/scrumHelper.js
Dropped manual cache refresh UI and messaging
  • Deleted refreshCache button handler and chrome.runtime.onMessage listener
  • Removed README section about new caching features
src/scripts/main.js
README.md
Minor cleanup of HTML/CSS and popup markup
  • Removed extra blank lines in popup.html and index.css
  • Trimmed redundant spacing in popup layout
src/popup.html
src/index.css

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

@hpdang hpdang merged commit 519366f into master Jun 16, 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 @hpdang - I've reviewed your changes and they look great!

Blocking issues:

  • User controlled data in methods like innerHTML, outerHTML or document.write is an anti-pattern that can lead to XSS vulnerabilities (link)
  • User controlled data in a scrumReport.innerHTML is an anti-pattern that can lead to XSS vulnerabilities (link)
Prompt for AI Agents
Please address the comments from this code review:
## Security Issues

### Issue 1
<location> `src/scripts/scrumHelper.js:297` </location>

<issue_to_address>
**security (insecure-document-method):** User controlled data in methods like `innerHTML`, `outerHTML` or `document.write` is an anti-pattern that can lead to XSS vulnerabilities

*Source: opengrep*
</issue_to_address>

### Issue 2
<location> `src/scripts/scrumHelper.js:297` </location>

<issue_to_address>
**security (insecure-innerhtml):** User controlled data in a `scrumReport.innerHTML` is an anti-pattern that can lead to XSS vulnerabilities

*Source: opengrep*
</issue_to_address>

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.

if (outputTarget === 'popup') {
const scrumReport = document.getElementById('scrumReport');
if (scrumReport) {
log("found div, updating content");
console.log("found div, updating content");
scrumReport.innerHTML = content;
Copy link
Contributor

Choose a reason for hiding this comment

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

security (insecure-document-method): User controlled data in methods like innerHTML, outerHTML or document.write is an anti-pattern that can lead to XSS vulnerabilities

Source: opengrep

if (outputTarget === 'popup') {
const scrumReport = document.getElementById('scrumReport');
if (scrumReport) {
log("found div, updating content");
console.log("found div, updating content");
scrumReport.innerHTML = content;
Copy link
Contributor

Choose a reason for hiding this comment

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

security (insecure-innerhtml): User controlled data in a scrumReport.innerHTML is an anti-pattern that can lead to XSS vulnerabilities

Source: opengrep

function handleEnableChange() {
let value = enableToggleElement.checked;
var value = enableToggleElement.checked;
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (code-quality): Use const or let instead of var. (avoid-using-var)

Explanation`const` is preferred as it ensures you cannot reassign references (which can lead to buggy and confusing code). `let` may be used if you need to reassign references - it's preferred to `var` because it is block- rather than function-scoped.

From the Airbnb JavaScript Style Guide

chrome.storage.local.set({ enableToggle: value });
}
function handleStartingDateChange() {
let value = startingDateElement.value;
var value = startingDateElement.value;
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (code-quality): Use const or let instead of var. (avoid-using-var)

Explanation`const` is preferred as it ensures you cannot reassign references (which can lead to buggy and confusing code). `let` may be used if you need to reassign references - it's preferred to `var` because it is block- rather than function-scoped.

From the Airbnb JavaScript Style Guide

chrome.storage.local.set({ startingDate: value });
}
function handleEndingDateChange() {
let value = endingDateElement.value;
var value = endingDateElement.value;
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (code-quality): Use const or let instead of var. (avoid-using-var)

Explanation`const` is preferred as it ensures you cannot reassign references (which can lead to buggy and confusing code). `let` may be used if you need to reassign references - it's preferred to `var` because it is block- rather than function-scoped.

From the Airbnb JavaScript Style Guide

var today = new Date();
var Week = new Date(today.getFullYear(), today.getMonth(), today.getDate());
var WeekMonth = Week.getMonth() + 1;
var WeekDay = Week.getDate();
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (code-quality): Use const or let instead of var. (avoid-using-var)

Explanation`const` is preferred as it ensures you cannot reassign references (which can lead to buggy and confusing code). `let` may be used if you need to reassign references - it's preferred to `var` because it is block- rather than function-scoped.

From the Airbnb JavaScript Style Guide

var Week = new Date(today.getFullYear(), today.getMonth(), today.getDate());
var WeekMonth = Week.getMonth() + 1;
var WeekDay = Week.getDate();
var WeekYear = Week.getFullYear();
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (code-quality): Use const or let instead of var. (avoid-using-var)

Explanation`const` is preferred as it ensures you cannot reassign references (which can lead to buggy and confusing code). `let` may be used if you need to reassign references - it's preferred to `var` because it is block- rather than function-scoped.

From the Airbnb JavaScript Style Guide

Comment on lines +173 to 237
key: oldCacheKey,
hasData: !!githubCache.data,
timestamp: githubCache.timestamp
// PR reviews fetch
var prUrl = 'https://api.github.com/search/issues?q=commenter%3A' +
githubUsername +
'+org%3Afossasia+updated%3A' +
startingDate +
'..' +
endingDate +
'&per_page=100';

$.ajax({
dataType: 'json',
type: 'GET',
url: prUrl,
error: (xhr, textStatus, errorThrown) => {
console.error('Error fetching PR reviews:', {
status: xhr.status,
textStatus: textStatus,
error: errorThrown
});
},
success: (data) => {
githubPrsReviewData = data;
writeGithubPrsReviews();
},
});

githubCache = {
data: null,
cacheKey: oldCacheKey,
timestamp: 0,
ttl: 5 * 60 * 1000,
fetching: false,
queue: [],
errors: {},
errorTTL: 60 * 1000,
subject: null
};

log('Cache reset complete');

await new Promise(resolve => {
chrome.storage.local.remove('githubCache', () => {
log('Storage cache cleared');
resolve();
});
// fetch github user data
var userUrl = 'https://api.github.com/users/' + githubUsername;
$.ajax({
dataType: 'json',
type: 'GET',
url: userUrl,
error: (xhr, textStatus, errorThrown) => {
// error
},
success: (data) => {
githubUserData = data;
},
});

try {
log('Starting fresh data fetch...');
await fetchGithubData();
log('Force refresh completed successfully');
return { success: true, timestamp: Date.now() };
} catch (err) {
logError('Force refresh failed:', err);
throw err;
}
}

function processGithubData(data) {
githubIssuesData = data.githubIssuesData;
githubPrsReviewData = data.githubPrsReviewData;
githubUserData = data.githubUserData;
prCommitsData = data.prCommitsData || {};

if (DEBUG) {
const commitCount = Object.values(prCommitsData)
.reduce((total, prs) => total + prs.reduce((count, pr) => count + pr.commits.length, 0), 0);

log('Data processed:', {
issues: githubIssuesData?.items?.length || 0,
prs: githubPrsReviewData?.items?.length || 0,
commits: commitCount
});
}

lastWeekArray = [];
nextWeekArray = [];
reviewedPrsArray = [];
commitsArray = [];
githubPrsReviewDataProccessed = {};

if (!githubCache.subject && scrumSubject) {
scrumSubjectLoaded();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (code-quality): Avoid function declarations, favouring function assignment expressions, inside blocks. (avoid-function-declarations-in-blocks)

ExplanationFunction declarations may be hoisted in Javascript, but the behaviour is inconsistent between browsers. Hoisting is generally confusing and should be avoided. Rather than using function declarations inside blocks, you should use function expressions, which create functions in-scope.

Comment on lines +174 to +180
var issueUrl = 'https://api.github.com/search/issues?q=author%3A' +
githubUsername +
'+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.

issue (code-quality): Use const or let instead of var. (avoid-using-var)

Explanation`const` is preferred as it ensures you cannot reassign references (which can lead to buggy and confusing code). `let` may be used if you need to reassign references - it's preferred to `var` because it is block- rather than function-scoped.

From the Airbnb JavaScript Style Guide

Comment on lines +200 to +206
var prUrl = 'https://api.github.com/search/issues?q=commenter%3A' +
githubUsername +
'+org%3Afossasia+updated%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.

issue (code-quality): Use const or let instead of var. (avoid-using-var)

Explanation`const` is preferred as it ensures you cannot reassign references (which can lead to buggy and confusing code). `let` may be used if you need to reassign references - it's preferred to `var` because it is block- rather than function-scoped.

From the Airbnb JavaScript Style Guide

@hpdang hpdang deleted the revert-114-commits-add branch June 18, 2025 07:27
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.

1 participant