Skip to content

feat: Implement Core PullRequestQuery Builder#38

Merged
github-actions[bot] merged 1 commit intomasterfrom
feature/pr-query-builder
Dec 20, 2025
Merged

feat: Implement Core PullRequestQuery Builder#38
github-actions[bot] merged 1 commit intomasterfrom
feature/pr-query-builder

Conversation

@jordanpartridge
Copy link
Copy Markdown
Contributor

@jordanpartridge jordanpartridge commented Dec 20, 2025

Summary

Implements the core PullRequestQuery builder with comprehensive fluent filtering API, addressing issue #20.

Enhanced Capabilities

Label Filtering

  • whereLabel(string $label) - Filter by single label (alias for existing label())
  • whereLabels(array $labels) - Filter by multiple labels (match any)
  • whereAllLabels(array $labels) - Filter by multiple labels (match all, client-side)

Execution Methods

  • exists(): bool - Check if any results exist
  • pluck(string $key): array - Extract a single field from all results

Fluent Aliases

  • whereOpen(), whereClosed(), whereState() - State filtering aliases
  • whereAuthor() - Author filtering alias
  • repo() - Repository context alias

Ordering Shortcuts

  • orderByCreated(string $direction = 'desc')
  • orderByUpdated(string $direction = 'desc')
  • orderByPopularity() - Order by comment count
  • orderByLongRunning() - Order by oldest updated first

Pagination

  • perPage(int $count) - Alias for take()

Implementation Details

  • All new methods maintain fluent chaining pattern
  • Client-side filtering added for whereAllLabels() to support complex label matching
  • Leverages existing QueryBuilder infrastructure
  • Full backward compatibility maintained

Test Coverage

  • 20 comprehensive tests covering all new features
  • 100% code coverage maintained
  • All existing tests passing (264 total tests)

Quality Gates

  • All tests passing
  • Code formatted with Laravel Pint
  • PHPStan compliant

Closes #20

Summary by CodeRabbit

Release Notes

  • New Features
    • Added new filtering methods for labels, state, and author
    • Introduced sorting shortcuts by creation date, update date, popularity, and long-running duration
    • Added result existence checking and field extraction capabilities
    • Enhanced label filtering with support for multiple label matching and filter combinations
    • Added pagination and repository name alias methods for convenience

✏️ Tip: You can customize this high-level summary in your review settings.

Enhanced QueryBuilder with comprehensive filtering and querying capabilities:

- Added label filtering: whereLabel(), whereLabels() (match any), whereAllLabels() (match all)
- Added execution methods: exists(), pluck()
- Added state filter aliases: whereOpen(), whereClosed(), whereState(), whereAuthor()
- Added ordering shortcuts: orderByCreated(), orderByUpdated(), orderByPopularity(), orderByLongRunning()
- Added pagination alias: perPage()
- Added repository alias: repo()
- Implemented client-side filtering for whereAllLabels()

All methods support fluent chaining and maintain existing QueryBuilder patterns.
100% test coverage with 20 new tests covering all enhanced features.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Dec 20, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request adds 15 public convenience methods to the QueryBuilder class, including filter aliases (whereLabel, whereOpen, whereClosed, whereState, whereAuthor), label filtering methods (whereLabels, whereAllLabels), ordering shortcuts (orderByCreated, orderByUpdated, orderByPopularity, orderByLongRunning), execution methods (exists, pluck), and utility aliases (perPage, repo). Client-side label filtering for _all_labels is introduced in the get() method. Comprehensive unit tests validate all new functionality.

Changes

Cohort / File(s) Change Summary
QueryBuilder convenience methods
src/QueryBuilder.php
Adds 15 public methods: filter aliases (whereLabel, whereLabels, whereAllLabels, whereOpen, whereClosed, whereState, whereAuthor), execution methods (exists, pluck), ordering shortcuts (orderByCreated, orderByUpdated, orderByPopularity, orderByLongRunning), pagination alias (perPage), and repository alias (repo). Implements client-side filtering for _all_labels in get() method.
Unit tests for enhanced QueryBuilder
tests/Unit/QueryBuilderEnhancedTest.php
New test suite with mock connector, response helpers, and factory functions. Covers alias methods, label filtering, existence checks, field extraction, sorting, method chaining, and edge cases (empty results, no labels).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

  • The changes consist primarily of straightforward method aliases and wrappers delegating to existing functionality
  • The client-side _all_labels filtering logic in get() is simple filtering logic without complex interactions
  • Test file follows repetitive patterns for similar test cases
  • Most methods require minimal review as they are simple pass-throughs to existing methods

Poem

🐰 A dozen shortcuts hopped in today,

Aliases bound in a fluent ballet,

Where labels now filter with grace,

And queries just chase at a sprightly pace,

The Builder now dances in code's grand way! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/pr-query-builder

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dfc8d3e and a459822.

📒 Files selected for processing (2)
  • src/QueryBuilder.php (3 hunks)
  • tests/Unit/QueryBuilderEnhancedTest.php (1 hunks)

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.

@github-actions github-actions bot merged commit d4d6b06 into master Dec 20, 2025
1 of 2 checks passed
@github-actions github-actions bot deleted the feature/pr-query-builder branch December 20, 2025 05:57
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.

Core: PullRequestQuery builder with fluent filtering API

1 participant