Skip to content

Refactor: Reduce GetTransactionSummaryByOperatorReport complexity (84 → 20 lines)#475

Merged
StuartFerguson merged 4 commits into
mainfrom
copilot/refactor-reporting-manager-method
Feb 28, 2026
Merged

Refactor: Reduce GetTransactionSummaryByOperatorReport complexity (84 → 20 lines)#475
StuartFerguson merged 4 commits into
mainfrom
copilot/refactor-reporting-manager-method

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 27, 2026

  • Refactor GetTransactionSummaryByOperatorReport to reduce method length from ~84 lines to ~20 lines
    • BuildOperatorTransactionBaseQuery — cyclomatic complexity reduced from 9 to 5 by extracting filter logic
    • ApplyOperatorTransactionFilters — new private static method handling merchant/operator filter application (complexity: 5)
    • BuildOperatorFinalSummaryQuery — operator-level aggregation query
    • BuildOperatorSummaryResponse — maps query results to response model
    • OperatorTransactionData private sealed class
    • OperatorSummaryData private sealed class
Original prompt

This section details on the original issue you should resolve

<issue_title>[Complexity] Method ReportingManager::GetTransactionSummaryByOperatorReport has 98 lines of code (limit is 50)</issue_title>
<issue_description>

Codacy ID: bbc9c306f27cba19c6cb23388cbd32ab

File: EstateReportingAPI.BusinessLogic/ReportingManager.cs
Line: 837
Rule: Complexity (Warning)
Commit: 73253a59c3ec40f1d1ebef7ed780c97b6526e2c3

Message: Method ReportingManager::GetTransactionSummaryByOperatorReport has 72 lines of code (limit is 50)

**Code Snippet:**
```csharp
    public async Task<Result<TransactionSummaryByOperatorResponse>> GetTransactionSummaryByOperatorReport(TransactionQueries.TransactionSummaryByOperatorQuery request, 
```

</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Refactor GetTransactionSummaryByOperatorReport method to reduce complexity Refactor: Reduce GetTransactionSummaryByOperatorReport complexity (84 → 20 lines) Feb 27, 2026
@StuartFerguson StuartFerguson marked this pull request as ready for review February 27, 2026 21:50
@StuartFerguson
Copy link
Copy Markdown
Member

@copilot codacy error
Method ReportingManager::BuildOperatorTransactionBaseQuery has a cyclomatic complexity of 9 (limit is 8)

…atorTransactionBaseQuery complexity

Co-authored-by: StuartFerguson <[email protected]>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 27, 2026

@copilot codacy error
Method ReportingManager::BuildOperatorTransactionBaseQuery has a cyclomatic complexity of 9 (limit is 8)

Fixed in 8af97d3. Extracted the merchant/operator filter logic from BuildOperatorTransactionBaseQuery into a new ApplyOperatorTransactionFilters private static method. This reduces BuildOperatorTransactionBaseQuery's cyclomatic complexity from 9 to 5, and the new filter method itself has a complexity of 5 — both well under the limit of 8.

@StuartFerguson StuartFerguson merged commit 82138eb into main Feb 28, 2026
8 checks passed
@github-actions github-actions Bot deleted the copilot/refactor-reporting-manager-method branch April 29, 2026 03:36
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.

[Complexity] Method ReportingManager::GetTransactionSummaryByOperatorReport has 98 lines of code (limit is 50)

2 participants