-
Notifications
You must be signed in to change notification settings - Fork 4
Add CompanyName filter to SearchCompaniesForAdmin endpoint #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: maximgorbatyuk <13348685+maximgorbatyuk@users.noreply.github.com>
Co-authored-by: maximgorbatyuk <13348685+maximgorbatyuk@users.noreply.github.com>
| var companyNameFilter = request.CompanyName?.Trim().ToLowerInvariant(); | ||
| var companies = await _context.Companies | ||
| .AsNoTracking() | ||
| .When(searchQuery?.Length >= 2, x => x.Name.ToLower().Contains(searchQuery)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this SearchQuery field from the request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the SearchQuery field from the request as requested. The endpoint now follows the same pattern as SearchUsersForAdmin, using only specific named filters (CompanyName). Commit: 51eff54
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. thnx
Co-authored-by: maximgorbatyuk <13348685+maximgorbatyuk@users.noreply.github.com>
| @@ -0,0 +1,121 @@ | |||
| using System.Collections.Generic; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pipeline is broken. Analyze and fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the pipeline issues caused by StyleCop violations in the test file. The build now passes successfully. Commit: 8b8e562
Co-authored-by: maximgorbatyuk <13348685+maximgorbatyuk@users.noreply.github.com>
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
This PR introduces a dedicated
CompanyNamefilter parameter to the Search Companies endpoint for admin users, providing more precise filtering capabilities for the frontend.Changes Made
Core Implementation
CompanyNameproperty toSearchCompaniesForAdminQueryParamswith default empty stringHasCompanyNameFilter()helper method following the same pattern as existing filtersAPI Usage
The endpoint now supports the following filtering options:
Key Features
Contains()for flexible search behaviorTest Coverage
Added comprehensive test suite covering:
Files Changed
SearchCompaniesForAdminQueryParams.cs: Added CompanyName property and helper method (5 lines added)SearchCompaniesForAdminHandler.cs: Added filtering logic and using statement (3 lines added)SearchCompaniesForAdminHandlerTests.cs: New comprehensive test suiteTechnical Notes
The implementation follows the established pattern used in
SearchUsersForAdmin, ensuring consistency across the codebase. The filtering logic uses Entity Framework'sWhenextension method for conditional query building, maintaining optimal query performance.Fixes #117.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.