Apply search filters on database search results#418
Apply search filters on database search results#418loic-sharma merged 5 commits intoloic-sharma:masterfrom
Conversation
|
|
||
| if (!string.IsNullOrEmpty(query)) | ||
| IQueryable<Package> ComposePackageQuery(IQueryable<Package> packageQuery) | ||
| { |
There was a problem hiding this comment.
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.
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.
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