Skip to content

fix(search): (#169) migrate deprecated GitHub search queries to advanced_search#584

Open
Shraddha3838 wants to merge 2 commits into
GitMetricsLab:mainfrom
Shraddha3838:fix/octokit-advanced-search-migration
Open

fix(search): (#169) migrate deprecated GitHub search queries to advanced_search#584
Shraddha3838 wants to merge 2 commits into
GitMetricsLab:mainfrom
Shraddha3838:fix/octokit-advanced-search-migration

Conversation

@Shraddha3838
Copy link
Copy Markdown

@Shraddha3838 Shraddha3838 commented May 27, 2026

Related Issue


Description

This PR updates deprecated GitHub Search API query usage by migrating affected frontend search requests to the newer advanced_search query format.

Changes made

  • Updated GitHub search query construction to use explicit AND-based query composition
  • Added advanced_search: true to affected /search/issues requests
  • Replaced manual query string construction with URLSearchParams
  • Added minimal typing improvement in useGitHubData.ts

Files changed

  • src/hooks/useGitHubData.ts
  • src/pages/ContributorProfile/ContributorProfile.tsx

Scope

The implementation was intentionally kept minimal and localized to the deprecated search query paths to avoid unrelated behavioral or architectural changes.


How Has This Been Tested?

  • npm run build passed successfully
  • ⚠️ npm run lint still reports existing unrelated repository issues outside the scope of this PR

Screenshots (if applicable)

N/A


Type of Change

  • Bug fix
  • New feature
  • Code style update
  • Breaking change
  • Documentation update

Summary by CodeRabbit

  • Refactor
    • Enhanced GitHub API query handling for improved reliability and type safety in data fetching operations.

Review Change Stack

@netlify
Copy link
Copy Markdown

netlify Bot commented May 27, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit 4612bd9
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a1773d881aeff00085c467d
😎 Deploy Preview https://deploy-preview-584--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Warning

Review limit reached

@Shraddha3838, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 19 minutes and 27 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4ea2c2d5-3613-4f79-aaef-32b49ae73f5c

📥 Commits

Reviewing files that changed from the base of the PR and between eab1673 and 4612bd9.

📒 Files selected for processing (2)
  • src/hooks/useGitHubData.ts
  • src/pages/ContributorProfile/ContributorProfile.tsx
📝 Walkthrough

Walkthrough

The PR refactors GitHub API search integration to address deprecations by introducing a typed schema for paginated responses, converting query construction from concatenation to array-based AND-joined parts, and adding explicit advanced search flags. Both the hook and consumer component are updated together to adopt the new pattern.

Changes

GitHub API Advanced Search Upgrade

Layer / File(s) Summary
Advanced search contract and query construction
src/hooks/useGitHubData.ts
PaginatedSearchResult type defines items and total for paginated search responses. Query construction is refactored from manual string concatenation into a queryParts array (author/is + optional title, repo, date bounds, state/merged filters) joined with AND. The Octokit request now explicitly sets advanced_search: true alongside the computed q parameter.
Typed concurrent request fetching and consumer integration
src/hooks/useGitHubData.ts, src/pages/ContributorProfile/ContributorProfile.tsx
The requests array for Promise.allSettled is tightened from Promise<any>[] to Promise<PaginatedSearchResult>[]. ContributorProfile switches from a hardcoded query string to constructing search parameters via URLSearchParams with advanced_search: "true", then serializes the parameters into the search API URL.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • GitMetricsLab/github_tracker#149: Both PRs modify src/hooks/useGitHubData.ts's GitHub Search request and pagination logic, including advanced search query construction and concurrent paginated fetching patterns.
  • GitMetricsLab/github_tracker#255: Both PRs refactor src/hooks/useGitHubData.ts to add advanced_search: true and construct typed paginated search result handling in overlapping code areas.

Suggested labels

quality:clean, level:intermediate, gssoc25

Poem

🐰 Advanced searches bloom so bright,
With types that hold the data tight,
Query parts join AND by AND,
The GitHub API now understands,
Deprecated paths give way to the new way.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: migrating deprecated GitHub search queries to the advanced_search format, directly aligned with the PR's primary objective.
Description check ✅ Passed The PR description includes all required template sections with sufficient detail: related issue, comprehensive description of changes, files modified, scope, testing results, and change type selection.
Linked Issues check ✅ Passed The PR fully addresses issue #169 by migrating deprecated GitHub Search API calls to the advanced_search format with explicit AND-based query composition and typing improvements.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the deprecated search query paths as intended; no unrelated behavioral or architectural modifications are present in the modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

🎉 Thank you @Shraddha3838 for your contribution. Please make sure your PR follows https://github.com/GitMetricsLab/github_tracker/blob/main/CONTRIBUTING.md#-pull-request-guidelines

Copy link
Copy Markdown
Contributor

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/hooks/useGitHubData.ts`:
- Line 57: The current push uses unquoted user input
(queryParts.push(`${filters.search} in:title`)); change it to push a properly
quoted and escaped title phrase by trimming filters.search, escaping any
embedded double quotes (e.g., replace " with \"), and wrapping the whole phrase
in quotes for GitHub like in:title:"<phrase>"; update the call that constructs
the query (queryParts.push(...)) in src/hooks/useGitHubData.ts to use the
trimmed-and-escaped filters.search inside in:title:"...".

In `@src/pages/ContributorProfile/ContributorProfile.tsx`:
- Around line 37-41: The code currently sets PRs from prsData.items without
checking the HTTP response; update the fetch logic in the ContributorProfile
component (the prsRes/prsData handling) to first verify prsRes.ok and handle
non-OK responses by parsing the error (or reading text), logging or storing the
error, and setting a safe fallback like setPRs([]) so the UI never receives
undefined for prs; ensure you still await prsRes.json() only for ok responses or
handle parsing errors gracefully.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ea993b53-16a8-45c4-90c9-5a7d1a78bb3d

📥 Commits

Reviewing files that changed from the base of the PR and between 4ae0ef6 and eab1673.

📒 Files selected for processing (2)
  • src/hooks/useGitHubData.ts
  • src/pages/ContributorProfile/ContributorProfile.tsx

Comment thread src/hooks/useGitHubData.ts Outdated
Comment thread src/pages/ContributorProfile/ContributorProfile.tsx Outdated
…defensive query sanitization and resilient fetch handling
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.

warn: Handle Github API deprecations

1 participant