-
Notifications
You must be signed in to change notification settings - Fork 644
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
Add UI for validation tables (just orchestrator tables) #4861
Conversation
@@ -7,12 +7,11 @@ | |||
namespace NuGetGallery | |||
{ | |||
public interface IEntityRepository<T> | |||
where T : class, IEntity, new() | |||
where T : class, new() |
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.
Simplified this interface to enable use on the ValidationEntitiesContext
.
src/NuGetGallery/UrlExtensions.cs
Outdated
IPackageVersionModel package, | ||
bool relativeUrl = true) | ||
{ | ||
return url.RevalidatePackage(package.Id, package.Version); |
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.
RevalidatePackage [](start = 23, length = 17)
Pass the relativeUrl
down.
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 catch
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.
} | ||
|
||
[HttpGet] | ||
public virtual async Task<ActionResult> Search(string vq) |
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.
vq [](start = 62, length = 2)
Nit: vq
is a strange name, could we use something like query
instead?
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.
v
alidation q
uery. I'll give the parameter a different name but I wanted to keep the query string short.
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 recommend q
instead of vq
as an abbreviation for the query string :)
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 was thinking this would collide with filling in the search box at the top of the page, but this behavior only exists on the package search page. Will 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.
await SearchByPackageIdAsync(validationSets, line); | ||
} | ||
|
||
var outputValidationSets = validationSets |
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.
outputValidationSets [](start = 16, length = 20)
Nit: return this directly instead of creating a variable?
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.
while ((line = stringReader.ReadLine()) != null) | ||
{ | ||
var normalizedLine = Regex.Replace(line.Trim(), @"\s+", " "); | ||
lines.Add(line); |
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.
line [](start = 30, length = 4)
Add the normalizedLine
, not the line
. Also, skip normalizedLine
s that are empty.
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.
string line; | ||
while ((line = stringReader.ReadLine()) != null) | ||
{ | ||
var normalizedLine = Regex.Replace(line.Trim(), @"\s+", " "); |
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.
Replace [](start = 47, length = 7)
Could you run the Regex.Replace
once on the entire query instead?
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.
@{ bool isFirst = true; } | ||
@foreach (var package in Model.Packages) | ||
{ | ||
if (!isFirst) |
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.
isFirst [](start = 13, length = 7)
Should this be if (isFirst)
?
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 entirely.
</thead> | ||
<tbody> | ||
@foreach (var validation in set.PackageValidations) | ||
{ |
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.
{ [](start = 24, length = 1)
Curly brace is off here.
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.
return View(); | ||
var viewModel = new HomeViewModel( | ||
showValidation: _config.Current.AsynchronousPackageValidationEnabled); | ||
|
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.
Will this ever be false?
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.
The default git clone
case is this (and NuGet.org, today).
_packages = packages ?? throw new ArgumentNullException(nameof(packages)); | ||
} | ||
|
||
public async Task<IReadOnlyList<PackageValidationSet>> SearchAsync(string 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.
It would be great to have comments at the method level.
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.
Sure
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.
} | ||
} | ||
|
||
private async Task SearchByValidationSetKeyAsync(Dictionary<long, PackageValidationSet> validationSets, string line) |
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.
line argument is more like a key. Can it be renamed to key?
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.
Line is not the key in all cases. It is just something that will be parsed for a DB query. I would rather keep the parameter name consistent.
.Include(x => x.PackageValidations) | ||
.Where(x => x.Key == integer) | ||
.FirstOrDefaultAsync(); | ||
|
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.
What is the state if the collection has more than 1 element? Should this case be asserted? (same for the other similar methods)
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.
This is not possible since Key
is the primary key of the PackageValidationSets
table.
await SearchByValidationIdAsync(validationSets, line); | ||
await SearchByValidationSetKeyAsync(validationSets, line); | ||
await SearchByPackageIdAndVersionAsync(validationSets, line); | ||
await SearchByPackageIdAsync(validationSets, line); |
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.
Does the order of invocation for these methods matter? Could be cases when they will override dictionary data for one call to the other?
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.
Order does not matter since the dictionary contains the whole package validation set.
@@ -172,6 +172,7 @@ | |||
<connectionStrings> | |||
<add name="Gallery.SqlServer" connectionString="Data Source=(localdb)\mssqllocaldb; Initial Catalog=NuGetGallery; Integrated Security=True; MultipleActiveResultSets=True" providerName="System.Data.SqlClient" /> | |||
<add name="Gallery.SupportRequestSqlServer" connectionString="Data Source=(localdb)\mssqllocaldb; Initial Catalog=SupportRequest; Integrated Security=True; MultipleActiveResultSets=True" providerName="System.Data.SqlClient" /> | |||
<add name="Validation.SqlServer" connectionString="Data Source=(localdb)\mssqllocaldb; Initial Catalog=Validation; Integrated Security=True; MultipleActiveResultSets=True" providerName="System.Data.SqlClient" /> |
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.
what would be the F5 experience of this? Will someone running the gallery on a clean PC have issue? We don't run migrations for Validation DB as part of the setup-devenvironment.ps1.
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.
F5 will not see this validation UI since asynchronous validation is disabled. The setup script should not create this database since it's not the default scenario (IMO).
|
||
namespace NuGetGallery.Areas.Admin.Models | ||
{ | ||
public enum DeletedStatus |
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.
PackageDeletedStatus for clearity
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.
string line; | ||
while ((line = stringReader.ReadLine()) != null) | ||
{ | ||
var normalizedLine = Regex.Replace(line.Trim(), @"\s+", " "); |
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.
can u add a timeout to the regex. Barry will like it :)
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.
Good catch.
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.
private async Task SearchByValidationSetTrackingIdAsync(Dictionary<long, PackageValidationSet> validationSets, string line) | ||
{ | ||
Guid guid; | ||
if (Guid.TryParse(line, out guid)) |
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.
nit: u can define the guid inline
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.
private async Task SearchByValidationSetTrackingIdAsync(Dictionary<long, PackageValidationSet> validationSets, string line) | ||
{ | ||
Guid guid; | ||
if (Guid.TryParse(line, out guid)) |
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.
nit: the SearchByX methods are very similar; I wonder if you could refactor for both code reuse and slight optimization.
For instance, if the caller does TryParse it would know whether to call specific SearchByX methods. Also, then you may be able to combine the core _validationSets SearchBy query into a single method that takes a filter.
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 chose not to perform these optimizations until we experience some painful performance. As the code is today, I think it's more readable.
{ | ||
private readonly ValidationEntitiesContext _entities; | ||
|
||
public ValidationEntityRepository(ValidationEntitiesContext entities) |
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.
Could EntityRepository be made more generic so that it could be reused for Validation? Maybe introduce an IEntitiesContextBase interface for the APIs shared across all EntityContexts:
- SaveChangesAsync
- Set
- DeleteOnCommit
- SetCommandTimeout
- GetDatabase
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 don't think an new base interface would help here. I will try to have a shared base class (implementation, not interface).
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.
These cannot share a base class since there is not common interface between IEntitiesContext
and ValidationEntitiesContext
.
|
||
namespace NuGetGallery.Areas.Admin.Services | ||
{ | ||
public class ValidationAdminService |
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.
didnt see UTs for this code
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.
Spoke extensively offline about this. I think they are not necessary in this case since the code is pretty simple but I would rather set the pattern here as there is no rush.
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.
@@ -105,5 +106,19 @@ | |||
Manage Namespace Reservation | |||
</p> | |||
</li> | |||
@if (Model.ShowValidation) |
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 like this approach. We show items in this menu that are not relevant for certain configs, and we shouldn't.
#4653
Admin page (notice last link)
Initial page
Search by ID
Search by ID + version
Search by validation set tracking ID
Search by validation ID