Skip to content

Conversation

@ArjinAlbay
Copy link
Member

@ArjinAlbay ArjinAlbay commented Aug 8, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a new client for fetching GitHub issues using the GraphQL API, enabling more flexible and efficient data retrieval.
    • Added a visual warning in page headers when API rate limits are critically low.
  • Enhancements

    • Expanded the range and freshness of issues sourced from GitHub by lowering repository star thresholds, increasing the number of issues fetched per repository, and filtering for more recently updated issues.
    • Improved cache management: quick wins cache now expires after 1 hour instead of 12 hours for more up-to-date results.
    • Manual refresh actions now clear the cache before fetching new data, ensuring the latest issues are displayed.
    • Removed API rate limit and cache status indicators from the Quick Wins page for a cleaner interface.
  • Refactor

    • Switched the data source for quick wins from REST to GraphQL, streamlining data handling and improving reliability.
    • Simplified initialization and refresh logic for fetching quick wins, resulting in more predictable and efficient behavior.
  • Bug Fixes

    • Ensured cached data is only used when it contains valid, non-empty results.
    • Standardized error messages for better clarity during failures.
  • Style

    • Improved the appearance of API rate limit warnings for better visibility.

@coderabbitai
Copy link

coderabbitai bot commented Aug 8, 2025

Walkthrough

This update migrates the "quick wins" issue-fetching logic from a REST-based GitHub API client to a new GraphQL client, revises the caching strategy to a 1-hour expiration, and adjusts the minimum repository star threshold for issue queries. It also moves the API rate limit warning UI from the Quick Wins page to the shared page header.

Changes

Cohort / File(s) Change Summary
Quick Wins Page UI Refactor
src/app/quick-wins/page.tsx
Removed CacheStatus and RateLimitWarning from imports and JSX; no logic changes.
Page Header Rate Limit Warning
src/components/layout/PageHeader.tsx
Added a critical API rate limit warning UI to the header, conditionally rendered based on remaining quota.
Quick Wins Hook Refactor
src/components/quick-wins/hooks/useQuickWins.ts
Refactored initialization to be idempotent and cache-aware; refresh functions now clear cache before fetching.
REST API Client Adjustments
src/lib/api/github-api-client.ts
Increased issues fetched per repo, added a since filter for recent issues, and lowered minimum star threshold for repositories.
New GraphQL API Client
src/lib/api/github-graphql-client.ts
Introduced a new GraphQL client class with methods for fetching and mapping issues, handling rate limits, and managing authentication tokens.
Cache Expiry Policy
src/stores/cache.ts
Changed quick wins cache expiration from 12 hours to 1 hour.
Quick Wins Store Refactor
src/stores/quickWins.ts
Switched from REST to GraphQL client for fetching issues, streamlined error handling, and improved cache checks and state management.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PageHeader
    participant useDataCacheStore
    participant GitHubGraphQLClient
    participant CacheStore
    participant QuickWinsStore

    User->>PageHeader: Loads page
    PageHeader->>useDataCacheStore: Get rateLimitInfo
    useDataCacheStore-->>PageHeader: Return rateLimitInfo
    PageHeader-->>User: Show rate limit warning if critical

    User->>QuickWinsStore: Request good issues/easy fixes
    QuickWinsStore->>CacheStore: Check cache (1 hour expiry)
    alt Cache valid and non-empty
        CacheStore-->>QuickWinsStore: Return cached issues
    else Cache expired/empty
        QuickWinsStore->>GitHubGraphQLClient: Set token and fetch issues
        GitHubGraphQLClient-->>QuickWinsStore: Return formatted issues
        QuickWinsStore->>CacheStore: Update cache
    end
    QuickWinsStore-->>User: Return issues
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~35 minutes

Possibly related PRs

  • HappyHackingSpace/githubmon#52: Initial implementation of the Quick Wins page, which is directly related to the refactoring and UI changes for rate limit warnings and issue fetching in this PR.

Poem

A bunny hopped through GraphQL fields,
Fetching issues, cache now yields.
One hour fresh, the data flows,
With warnings high when limit’s low.
Headers blink with amber light—
Quick wins now feel just right!
🐇✨

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5003123 and 6bc8ca8.

📒 Files selected for processing (1)
  • src/lib/api/github-api-client.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/api/github-api-client.ts
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (5)
src/stores/cache.ts (1)

60-63: Extract reusable constant & unify comment language

ONE_HOUR_IN_MS is re-declared every time isQuickWinsCacheExpired runs and the inline comment is Turkish (“1 saat”) while the rest of the file is English.
Move the constant to module scope (or a shared constants.ts) and keep comment language consistent.

src/lib/api/github-graphql-client.ts (1)

294-304: Duplicate “high” check – consider tightening priority rules

calculatePriority has two branches that both return 'high'. Consolidating them (or adding a medium branch for “p1/high”) would simplify the function.

src/lib/api/github-api-client.ts (3)

430-434: Default issuesPerRepo raised to 30 – double-check rate-limit impact

With 20 repos × labels.length requests per batch, bumping the default to 30 can push the overall request count (and payload size) far higher than before, especially when the caller doesn’t override the parameter.
Confirm the new default won’t hit the REST v3 rate limit for unauthenticated users (60 req/h) or authenticated users (5 k req/h) and that the UX can tolerate the extra latency.


436-439: since filter uses date-only ISO – prefer full timestamp for accuracy

GitHub’s since parameter accepts full RFC 3339 timestamps. Passing only YYYY-MM-DD zero-times it at 00:00 UTC, which can exclude ~24 h of issues on the boundary day.
Consider:

-const dateString = oneMonthAgo.toISOString().split('T')[0]
+const dateString = oneMonthAgo.toISOString()

This keeps precision while remaining standards-compliant.


456-458: Endpoint lacks explicit sort parameter

/issues defaults to created sorting. If the goal is to surface recent activity, add &sort=updated&direction=desc to the query string; otherwise the since filter alone may still return month-old but least-recently-created issues first.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b60330 and fca37d7.

📒 Files selected for processing (7)
  • src/app/quick-wins/page.tsx (0 hunks)
  • src/components/layout/PageHeader.tsx (2 hunks)
  • src/components/quick-wins/hooks/useQuickWins.ts (4 hunks)
  • src/lib/api/github-api-client.ts (3 hunks)
  • src/lib/api/github-graphql-client.ts (1 hunks)
  • src/stores/cache.ts (1 hunks)
  • src/stores/quickWins.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • src/app/quick-wins/page.tsx
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/components/layout/PageHeader.tsx (1)
src/hooks/useAuth.ts (1)
  • useRequireAuth (22-30)
🔇 Additional comments (6)
src/components/layout/PageHeader.tsx (2)

14-18: LGTM – clear critical-limit calculation

Computation is straightforward and handles both “0 remaining” and “<10 % left”.


32-40: LGTM – concise, accessible warning UI

Conditional render and colour choice are appropriate; no issues spotted.

src/components/quick-wins/hooks/useQuickWins.ts (1)

104-113: LGTM – manual refresh correctly invalidates cache

Cache is cleared before each forced fetch; behaviour matches new 1-hour policy.

src/stores/quickWins.ts (1)

42-52: LGTM – early-return from cache avoids unnecessary calls

Cache check now validates non-empty arrays; good improvement.

src/lib/api/github-api-client.ts (2)

506-508: Star threshold dropped to 5 – verify signal-to-noise ratio

Reducing the floor from 20→5 will pull in a long tail of little-known projects. That may dilute “quick wins” quality or bloat API traffic. Validate the new threshold against user expectations and adjust if noise becomes an issue.


510-512: Low threshold + broad label set – monitor result relevance

Combining a 5-star minimum with five generic labels could return large, low-quality batches. Track cache hit rate and user clicks to ensure the feed stays useful; consider paginating or tightening filters if necessary.

Comment on lines +191 to +199
for (const label of labels) {
const query = `
query GetEasyFixes($count: Int!) {
search(
query: "label:\\"${label}\\" state:open created:>${dateString}",
type: ISSUE,
first: $count
) {
nodes {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Math.floor(count / labels.length) may pass 0 – GraphQL rejects it

When count < labels.length the computed per-label count is 0, leading to a first: 0 query which GitHub rejects.

Guard with Math.max(1, …) or skip the query for that label.

- const perLabel = Math.floor(count / labels.length)
+ const perLabel = Math.max(1, Math.floor(count / labels.length))

Also applies to: 247-249

🤖 Prompt for AI Agents
In src/lib/api/github-graphql-client.ts around lines 191 to 199 and also lines
247 to 249, the calculation using Math.floor(count / labels.length) can result
in 0 when count is less than labels.length, causing the GraphQL query to fail
with first: 0. To fix this, update the calculation to use Math.max(1,
Math.floor(count / labels.length)) to ensure the count is never zero, or
alternatively skip the query for that label if the computed count is zero.

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