Skip to content

Conversation

@vedansh-5
Copy link
Member

@vedansh-5 vedansh-5 commented Jul 5, 2025

📌 Fixes

Fixes #179


Caching works as intended now.

📸 Screenshots / Demo (if UI-related)

cacheFix.mp4

✅ 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

Add any special notes for the reviewer here

Summary by Sourcery

Bug Fixes:

  • Replace bitwise & with logical && in cache conditionals to correctly evaluate cache freshness and key matching.

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

sourcery-ai bot commented Jul 5, 2025

Reviewer's Guide

Replaced bitwise operators with logical AND in the allIncluded function’s cache validation and token logic to ensure the cache is correctly invalidated when token state changes.

Class diagram for updated cache validation logic in scrumHelper.js

classDiagram
    class scrumHelper {
        +allIncluded(outputTarget)
    }
    class githubCache {
        +data
        +cacheKey
        +usedToken
    }
    class githubToken
    scrumHelper --> githubCache : uses
    scrumHelper --> githubToken : checks
Loading

File-Level Changes

Change Details Files
Conditionals updated from bitwise to logical operators to correctly validate cache freshness and token requirements.
  • Replaced & with && in the cache freshness and key-match check
  • Replaced & with && in the token requirement check
src/scripts/scrumHelper.js

Assessment against linked issues

Issue Objective Addressed Explanation
#179 Ensure that cached data is used when available and valid, preventing unnecessary fetch requests.

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

@vedansh-5 vedansh-5 requested a review from hpdang July 5, 2025 13:04
@vedansh-5 vedansh-5 self-assigned this Jul 5, 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 @vedansh-5 - I've reviewed your changes - here's some feedback:

  • Consider adding an ESLint rule or custom lint check to flag accidental use of bitwise & in boolean expressions to prevent similar bugs.
  • Add a focused unit test for the branch that invalidates the cache when a token becomes available after the cache was fetched without one.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider adding an ESLint rule or custom lint check to flag accidental use of bitwise `&` in boolean expressions to prevent similar bugs.
- Add a focused unit test for the branch that invalidates the cache when a token becomes available after the cache was fetched without one.

## Individual Comments

### Comment 1
<location> `src/scripts/scrumHelper.js:359` </location>
<code_context>
         const needsToken = !!githubToken;
         const cacheUsedToken = !!githubCache.usedToken;
-        if (githubCache.data && isCacheFresh & isCacheKeyMatch) { //should be && check after rebase
-            if (needsToken & !cacheUsedToken) {
+        if (githubCache.data && isCacheFresh && isCacheKeyMatch) { 
+            if (needsToken && !cacheUsedToken) {
</code_context>

<issue_to_address>
Bitwise AND replaced with logical AND for boolean check.

Using '&&' instead of '&' ensures proper boolean evaluation and prevents unintended behavior when operands are not strictly boolean.
</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.

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

image
This is not showing the commits made on existing PRs . Please fix that .Thanks!

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

Works properly now, thanks @Preeti9764 for pointing it out, since I had no open PRs I couldn't check it, and I try it with different timeline assuming it would be working as expected given that I had not touched the code for the concerned feature.
The issue is fixed now.
image

@Preeti9764
Copy link
Contributor

Igtm ! Thanks.

@vedansh-5
Copy link
Member Author

@hpdang Resolved the conflicts.

@hpdang hpdang merged commit c8edbf6 into fossasia:master Jul 7, 2025
@vedansh-5 vedansh-5 deleted the cacheBug branch August 1, 2025 13:22
@vedansh-5 vedansh-5 changed the title caching bug fixed patch: caching bug fixed Aug 4, 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.

[Bug] Caching mechanism ineffective since last merge.

3 participants