-
Notifications
You must be signed in to change notification settings - Fork 694
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Apply search filters on database search results #418
Apply search filters on database search results #418
Conversation
@@ -178,32 +178,39 @@ public Task IndexAsync(Package package, CancellationToken cancellationToken) | |||
var frameworks = GetCompatibleFrameworksOrNull(framework); | |||
var search = (IQueryable<Package>)_context.Packages.Where(p => p.Listed); | |||
|
|||
if (!string.IsNullOrEmpty(query)) | |||
IQueryable<Package> ComposePackageQuery(IQueryable<Package> packageQuery) | |||
{ |
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.
We could add packageQuery = packageQuery.Where(p => p.Listed);
here.
This lets you simplify line 179 to:
var search = AddSearchFilters(_context.Packages);
And lines 237-239 to:
var results = await AddSearchFilters(search).ToListAsync(cancellationToken);
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.
I would like to change/update search
before using it. Maybe someone later will add some more lines of code, and I would like to have this filtering in that search already. Please let me know if you agree with it.
if (!string.IsNullOrEmpty(query)) | ||
{ | ||
query = query.ToLower(); | ||
packageQuery = packageQuery.Where(p => p.Id.ToLower().Contains(query)); |
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.
We only need to filter on query
once, could you move lines 183-187 out of ComposePackageQuery
? I would make line 179 something like:
var search = AddSearchFilters(_context.Packages);
if (!string.IsNullOrEmpty(query))
{
query = query.ToLower();
search = search.Where(p => p.Id.ToLower().Contains(query));
}
var packageIds = ...
Thank you for opening this! I left some minor suggestions, I'll merge this in once you've replied 😊 |
Co-Authored-By: Loïc Sharma <sharma.loic@gmail.com>
Your changes look good. Before I merge this in, I will run the following test plan:
function Push {
param (
$PackageId,
$PackageVersion
)
$normalizedVersion = $PackageVersion.Split('+')[0]
& dotnet pack /p:PackageId=$PackageId /p:PackageVersion=$PackageVersion
& dotnet nuget push "./bin/Debug/${PackageId}.${normalizedVersion}.nupkg" -s http://localhost:50561/v3/index.json
}
Push "normal" "1.0.0"
Push "prerelease" "1.0.0-prerelease"
Push "semver2" "1.0.0+semver2"
Push "both" "1.0.0-prerelease+semver2"
Push "all" "1.0.0"
Push "all" "2.0.0-prerelease"
Push "all" "3.0.0+semver2"
Push "all" "4.0.0-prerelease+semver2" |
Thank you for fixing this! |
Summary of the changes (in less than 80 chars)
Addresses #417