Skip to content

Conversation

@amargiovanni
Copy link
Contributor

Summary

  • Activity-based filtering for repository selection in [A], [L], [O] options
  • GitHub Search API integration with org: and pushed:> qualifiers for efficient org filtering
  • Activity statistics display: "N repos found, M with activity in last X days" (FR-007)
  • Confirmation prompts with [Y/n/all] to proceed with filtered repos or bypass filter
  • Graceful degradation: rate limit fallback to unfiltered mode (FR-008), zero-results handling (FR-009)

Changes

  • src/github_analyzer/api/client.py: Added search_repos() and search_active_org_repos() methods
  • src/github_analyzer/cli/main.py: Added filtering helpers (get_cutoff_date, filter_by_activity, display_activity_stats), modified select_github_repos() with --days parameter
  • tests/integration/test_smart_filter.py: 24 new integration tests
  • tests/unit/: 20 new unit tests for API and CLI components

Test plan

  • All 162 tests pass (118 unit + 44 feature)
  • pytest tests/ -v confirms no regressions
  • Lint passes (ruff check)
  • Manual test: Run analyzer with [A] option, verify stats display
  • Manual test: Run analyzer with [O] option, verify Search API filtering
  • Manual test: Respond "all" to bypass filter

Feature 005 design artifacts:
- spec.md: 3 user stories, 10 functional requirements, 5 success criteria
- plan.md: Technical context, constitution check, project structure
- research.md: GitHub Search API research and implementation strategy
- data-model.md: Entity definitions (ActivityFilterSettings, ActivityStatistics)
- contracts/search-api.md: GitHub Search API contract
- quickstart.md: Usage guide with examples
- tasks.md: 41 tasks organized by user story (TDD approach)
- checklists/: Requirements quality validation (52 items)

Key decisions:
- Hybrid approach: Search API for org repos, client-side for personal
- Graceful fallback on rate limit (FR-008)
- Uses existing --days parameter for cutoff calculation
Resolve all 52 checklist items in comprehensive.md by enhancing spec.md:

- Add glossary defining active/inactive repo, cutoff date, pushed_at
- Expand FR-002 with ISO 8601 format and exact filtering logic
- Detail FR-003/FR-004 behavior for each menu option [A], [L], [O]
- Document FR-006 confirmation prompt options (Y/n/all)
- Specify FR-008 fallback steps for rate limit, server errors, timeout
- Add FR-010 default behavior when --days not provided
- Expand edge cases from 5 to 10 with exact error messages
- Clarify SC-001/SC-005 timing measurements
- Add SC-006 memory efficiency requirement
- Add Performance Requirements table with limits per scenario
- Add API Constraints section (rate limits, query limits)
- Add Dependencies section with validated internal/external deps
- Add Design Decisions section justifying hybrid approach
- Quantify time savings in US1/US2 (~80%, ~90%)
Add activity-based filtering to repository selection for [A], [L], [O] options:

- Add search_repos() and search_active_org_repos() to GitHubClient
- Implement get_cutoff_date(), filter_by_activity(), display_activity_stats() helpers
- Modify select_github_repos() with --days parameter and confirmation prompts
- Use Search API (org:+pushed:>) for efficient org filtering
- Add rate limit fallback and zero-results handling per FR-008/FR-009

Tests: 162 passing (118 unit + 44 feature integration)
Tasks: 41/41 completed per tasks.md
@gemini-code-assist
Copy link

Summary of Changes

Hello @amargiovanni, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the repository selection experience by introducing a 'Smart Repository Filtering' feature. It intelligently filters GitHub repositories based on their recent activity, allowing users to concentrate their analysis on actively maintained projects. The implementation includes efficient integration with the GitHub Search API for organization repositories, clear activity statistics, and user-friendly prompts to manage filtering preferences, alongside robust error handling for various API and data scenarios.

Highlights

  • Activity-Based Repository Filtering: Introduced intelligent filtering for repository selection based on recent activity, allowing users to focus on actively maintained projects.
  • GitHub Search API Integration: Leveraged the GitHub Search API with org: and pushed:> qualifiers for efficient server-side filtering of organization repositories, improving performance for large organizations.
  • Activity Statistics Display: Implemented the display of clear activity statistics, showing 'N repos found, M with activity in last X days' to inform users about the filtering.
  • Interactive Confirmation Prompts: Added confirmation prompts with [Y/n/all] options, giving users control to proceed with filtered repositories or bypass the activity filter entirely.
  • Graceful Degradation: Ensured robust error handling for scenarios like API rate limits (falling back to unfiltered mode) and zero active results (offering options to adjust timeframe or include all repos).
  • New API Client Methods: Added search_repos() and search_active_org_repos() methods to the GitHub API client for interacting with the GitHub Search API.
  • CLI Filtering Logic: Integrated new helper functions (get_cutoff_date, filter_by_activity, display_activity_stats) and the --days parameter into the CLI's repository selection process.
  • Comprehensive Testing: Included extensive new unit and integration tests (24 integration, 20 unit) to ensure the correctness and reliability of the smart filtering feature.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is an excellent pull request that introduces a valuable smart filtering feature. The changes are comprehensive, covering not only the implementation but also extensive documentation, specifications, and tests. The code is well-structured, clean, and follows existing patterns in the codebase. I've identified a couple of minor areas for improvement to enhance robustness and fully align the implementation with the detailed specifications provided.

Comment on lines +723 to +732
if not active_repos:
print(f"⚠️ No repositories have been pushed to in the last {days} days.")
try:
zero_choice = input("Options: [1] Include all repos, [2] Cancel: ").strip()
except (EOFError, KeyboardInterrupt):
return []
if zero_choice == "1":
active_repos = repos
else:
continue

Choose a reason for hiding this comment

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

medium

The handling for zero active repositories is missing the "Adjust timeframe" option that is documented in the feature specification (spec.md, Edge Case #1) and quickstart.md. The current implementation only offers to include all repos or cancel. Adding the option to adjust the timeframe would improve the user experience and align the implementation with the documentation. A more complete implementation could loop to allow the user to enter a new timeframe and re-filter.

Comment on lines +883 to +884
except (EOFError, KeyboardInterrupt, GitHubAnalyzerError):
pass

Choose a reason for hiding this comment

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

medium

This except block is too broad and silently ignores all GitHubAnalyzerError exceptions that might occur during the fallback process. This could hide important issues, such as authentication problems or other API errors when trying to fetch the unfiltered list of organization repositories. It would be more robust to handle user cancellation (EOFError, KeyboardInterrupt) separately from actual application errors (GitHubAnalyzerError).

Suggested change
except (EOFError, KeyboardInterrupt, GitHubAnalyzerError):
pass
except (EOFError, KeyboardInterrupt):
# User cancelled the fallback selection
pass
except GitHubAnalyzerError as e:
# Log the error that occurred during fallback
log(f"Error during fallback: {e.message}", "error")

Add Callable[[str, str], None] type hint to satisfy mypy.
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.

2 participants