Skip to content

Conversation

@jordanpartridge
Copy link
Contributor

Summary

Implements batch operation support and higher-order collection methods for performing actions on multiple issues at once, as specified in issue #27.

Changes

IssueCollection Class (src/Support/IssueCollection.php)

A custom collection class extending Laravel's Collection with specialized methods for working with issues:

Filtering Methods:

  • withLabel(string $label) - Filter issues with a specific label
  • withoutLabel(string $label) - Filter issues without a specific label
  • open() - Filter open issues
  • closed() - Filter closed issues
  • assigned() - Filter assigned issues
  • unassigned() - Filter unassigned issues

Grouping Methods:

  • groupByLabel() - Group issues by their labels
  • groupByState() - Group issues by state (open/closed)
  • groupByAssignee() - Group issues by assignee (with "unassigned" group)

Analysis:

  • statistics() - Get comprehensive statistics about the collection

BatchOperations Service (src/Services/BatchOperations.php)

A service class for performing bulk operations on issues:

  • batch(IssueCollection $issues, callable $operation, ?callable $progress) - Process issues in batch with:
    • Individual error handling (continues on failure)
    • Progress tracking callback support
    • Detailed success/failure results

Updated IssueQuery (src/Services/IssueQuery.php)

  • Changed return type from Collection to IssueCollection
  • Enables higher-order proxy pattern: $issues->each->method()
  • Provides access to specialized collection methods

Usage Examples

// Simple filtering
$bugs = Issues::forRepo('owner/repo')
    ->whereOpen()
    ->get()
    ->withLabel('bug');

// Chained filtering
$unassignedBugs = Issues::forRepo('owner/repo')
    ->whereOpen()
    ->get()
    ->withLabel('bug')
    ->unassigned();

// Grouping
$byAssignee = Issues::forRepo('owner/repo')
    ->whereOpen()
    ->get()
    ->groupByAssignee();

foreach ($byAssignee as $assignee => $issues) {
    echo "{$assignee} has {$issues->count()} issues\n";
}

// Statistics
$stats = Issues::forRepo('owner/repo')
    ->whereOpen()
    ->get()
    ->statistics();
// Returns: ['total', 'open', 'closed', 'assigned', 'unassigned', 'labels', 'assignees']

// Batch operations with progress tracking
$batch = new BatchOperations($connector, 'owner', 'repo');
$results = $batch->batch(
    $issues,
    fn($issue) => processIssue($issue),
    fn($current, $total, $issue) => echo "Processing {$current}/{$total}\n"
);

Testing

  • ✅ Full test coverage for IssueCollection with 14 test cases
  • ✅ Full test coverage for BatchOperations with 8 test cases
  • ✅ Updated IssueQuery tests to expect IssueCollection
  • ✅ All 326 tests passing
  • ✅ Laravel Pint formatting applied

Implementation Notes

  • Maintains backward compatibility (IssueCollection extends Collection)
  • Error handling in batch operations captures exceptions without stopping
  • Progress callbacks are optional
  • Grouping methods handle edge cases (empty assignees, multiple labels, etc.)
  • Statistics method provides comprehensive analysis in single call

Closes #27

…27)

- Add IssueCollection class extending Laravel Collection
  - Filtering methods: withLabel, withoutLabel, open, closed, assigned, unassigned
  - Grouping methods: groupByLabel, groupByState, groupByAssignee
  - Statistics method for collection analysis

- Add BatchOperations service for bulk issue operations
  - Batch processing with error handling
  - Progress tracking support
  - Graceful exception handling

- Update IssueQuery to return IssueCollection instead of Collection
  - Enables higher-order proxy pattern ($collection->each->method())
  - Provides specialized filtering and grouping capabilities

- Comprehensive test coverage for all new functionality
  - IssueCollection filtering and grouping tests
  - BatchOperations processing and error handling tests
  - Updated IssueQuery tests for IssueCollection return type

Closes #27
@coderabbitai
Copy link

coderabbitai bot commented Dec 20, 2025

Warning

Rate limit exceeded

@jordanpartridge has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 15 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between aaa4003 and 03dbeb3.

📒 Files selected for processing (6)
  • src/Services/BatchOperations.php (1 hunks)
  • src/Services/IssueQuery.php (3 hunks)
  • src/Support/IssueCollection.php (1 hunks)
  • tests/Unit/Services/BatchOperationsTest.php (1 hunks)
  • tests/Unit/Services/IssueQueryTest.php (2 hunks)
  • tests/Unit/Support/IssueCollectionTest.php (1 hunks)
✨ 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/27-batch-operations

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.

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.

Implement Batch Operations and Higher-Order Collection Methods

2 participants