Skip to content
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

Do not show organization packages on profile #5349

Merged
merged 2 commits into from
Jan 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/NuGetGallery/Controllers/UsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ public virtual ActionResult Profiles(string username, int page = 1)
return HttpNotFound();
}

var packages = _packageService.FindPackagesByAnyMatchingOwner(user, includeUnlisted: false)
var packages = _packageService.FindPackagesByOwner(user, includeUnlisted: false)
.OrderByDescending(p => p.PackageRegistration.DownloadCount)
.Select(p => new ListPackageItemViewModel(p, user)
{
Expand Down
5 changes: 5 additions & 0 deletions src/NuGetGallery/Services/IPackageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ public interface IPackageService : ICorePackageService
Package FindPackageByIdAndVersion(string id, string version, int? semVerLevelKey = null, bool allowPrerelease = true);

Package FindAbsoluteLatestPackageById(string id, int? semVerLevelKey);

IEnumerable<Package> FindPackagesByOwner(User user, bool includeUnlisted, bool includeVersions = false);

IEnumerable<Package> FindPackagesByAnyMatchingOwner(User user, bool includeUnlisted, bool includeVersions = false);

IEnumerable<PackageRegistration> FindPackageRegistrationsByOwner(User user);

IEnumerable<Package> FindDependentPackages(Package package);

/// <summary>
Expand Down
21 changes: 13 additions & 8 deletions src/NuGetGallery/Services/PackageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ public virtual Package FindAbsoluteLatestPackageById(string id, int? semVerLevel
return package;
}

public IEnumerable<Package> FindPackagesByOwner(User user, bool includeUnlisted, bool includeVersions = false)
{
var packages = GetPackagesForOwners(new[] { user.Key }, includeUnlisted);

return includeVersions
? packages
: GetLatestPackageForEachRegistration(packages.ToList());
}

/// <summary>
/// Find packages by owner, including organization owners that the user belongs to.
/// </summary>
Expand All @@ -220,14 +229,10 @@ public IEnumerable<Package> FindPackagesByAnyMatchingOwner(User user, bool inclu
ownerKeys.Insert(0, user.Key);

var packages = GetPackagesForOwners(ownerKeys, includeUnlisted);
if (includeVersions)
{
return packages;
}
else
{
return GetLatestPackageForEachRegistration(packages.ToList());
}

return includeVersions
? packages
: GetLatestPackageForEachRegistration(packages.ToList());
}

private IEnumerable<Package> GetLatestPackageForEachRegistration(IReadOnlyCollection<Package> packages)
Expand Down
Loading