Skip to content

Commit

Permalink
Merge branch '1495_changes' into stable
Browse files Browse the repository at this point in the history
* 1495_changes:
  (GH-1397) Reduce traffic - choco queries
  (GH-1397) Speed up choco outdated
  • Loading branch information
ferventcoder committed Oct 2, 2018
2 parents b4b7b7f + 7788964 commit 31fe5e3
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 35 deletions.
7 changes: 2 additions & 5 deletions src/chocolatey.sln
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
MinimumVisualStudioVersion = 10.0.40219.1
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "chocolatey.console", "chocolatey.console\chocolatey.console.csproj", "{E24E3386-244F-4404-9E6E-5B53818EA903}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "chocolatey.tests", "chocolatey.tests\chocolatey.tests.csproj", "{5C4C60F0-47B1-498E-ABF7-D315E1A94BC9}"
Expand Down Expand Up @@ -42,7 +40,6 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "toplevel", "toplevel", "{18FEFF9F-7352-4230-8B4E-E8D8BE976095}"
ProjectSection(SolutionItems) = preProject
..\CHANGELOG.md = ..\CHANGELOG.md
..\COMMITTERS.md = ..\COMMITTERS.md
..\CONTRIBUTING.md = ..\CONTRIBUTING.md
..\README.md = ..\README.md
EndProjectSection
Expand Down Expand Up @@ -138,8 +135,8 @@ Global
{5C4C60F0-47B1-498E-ABF7-D315E1A94BC9} = {7656D054-387D-409C-A9FB-62A44599AA77}
{12ECAD4F-D463-4D72-A792-A4FCCFE9C456} = {7656D054-387D-409C-A9FB-62A44599AA77}
{DAB29F30-149D-4005-A8D2-4FA56CF2784D} = {FB6236DD-17EF-4C36-943C-47792FBC3306}
{E5C987F8-6B95-4835-BBDD-A25C9D370BB9} = {DAB29F30-149D-4005-A8D2-4FA56CF2784D}
{DD9689F3-1D2D-41AE-A672-063EE70C0C9A} = {FB6236DD-17EF-4C36-943C-47792FBC3306}
{E5C987F8-6B95-4835-BBDD-A25C9D370BB9} = {DAB29F30-149D-4005-A8D2-4FA56CF2784D}

This comment has been minimized.

Copy link
@ferventcoder

ferventcoder Oct 2, 2018

Author Member

I am not sure how that crept in... going to have to change that back out.

EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {998CAC46-A2B8-447C-B4CC-3B11DC35ED46}
Expand Down
16 changes: 8 additions & 8 deletions src/chocolatey/infrastructure.app/nuget/NugetList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ private static IQueryable<IPackage> execute_package_search(ChocolateyConfigurati
// 2. Does it support prerelease in a straight-forward way?
// Choco previously dealt with this by taking the path of least resistance and manually filtering out and sort unwanted packages
// This result in blocking operations that didn't let service based repositories, like OData, take care of heavy lifting on the server.
bool isRemote;
bool isServiceBased;
var aggregateRepo = packageRepository as AggregateRepository;
if (aggregateRepo != null)
{
isRemote = aggregateRepo.Repositories.All(repo => repo is IServiceBasedRepository);
isServiceBased = aggregateRepo.Repositories.All(repo => repo is IServiceBasedRepository);
}
else
{
isRemote = packageRepository is IServiceBasedRepository;
isServiceBased = packageRepository is IServiceBasedRepository;
}

IQueryable<IPackage> results = packageRepository.Search(searchTermLower, configuration.Prerelease);
Expand All @@ -72,21 +72,21 @@ private static IQueryable<IPackage> execute_package_search(ChocolateyConfigurati

if (configuration.ListCommand.ByIdOnly)
{
results = isRemote ?
results = isServiceBased ?
results.Where(p => p.Id.ToLower().Contains(searchTermLower))
: results.Where(p => p.Id.contains(searchTermLower, StringComparison.OrdinalIgnoreCase));
}

if (configuration.ListCommand.ByTagOnly)
{
results = isRemote
results = isServiceBased
? results.Where(p => p.Tags.Contains(searchTermLower))
: results.Where(p => p.Tags.contains(searchTermLower, StringComparison.InvariantCultureIgnoreCase));
}

if (configuration.ListCommand.IdStartsWith)
{
results = isRemote ?
results = isServiceBased ?
results.Where(p => p.Id.ToLower().StartsWith(searchTermLower))
: results.Where(p => p.Id.StartsWith(searchTermLower, StringComparison.OrdinalIgnoreCase));
}
Expand All @@ -108,7 +108,7 @@ private static IQueryable<IPackage> execute_package_search(ChocolateyConfigurati

if (configuration.AllVersions || !string.IsNullOrWhiteSpace(configuration.Version))
{
if (isRemote)
if (isServiceBased)
{
return results.OrderBy(p => p.Id).ThenByDescending(p => p.Version);
}
Expand All @@ -127,7 +127,7 @@ private static IQueryable<IPackage> execute_package_search(ChocolateyConfigurati
results = results.Where(p => p.IsLatestVersion);
}

if (!isRemote)
if (!isServiceBased)
{
results =
results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Output is package name | current version | available version | pinned?

var output = config.RegularOutput;
config.RegularOutput = false;
var oudatedPackages = _nugetService.upgrade_noop(config, null);
var oudatedPackages = _nugetService.get_outdated(config);
config.RegularOutput = output;

if (config.RegularOutput)
Expand Down
12 changes: 10 additions & 2 deletions src/chocolatey/infrastructure.app/services/INugetService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@

namespace chocolatey.infrastructure.app.services
{
using configuration;
using chocolatey.infrastructure.results;
using configuration;
using System.Collections.Concurrent;

public interface INugetService : ISourceRunner
public interface INugetService : ISourceRunner
{
/// <summary>
/// Run pack in noop mode.
Expand Down Expand Up @@ -49,5 +51,11 @@ public interface INugetService : ISourceRunner
/// </summary>
/// <param name="packageName">Name of the package.</param>
void remove_rollback_directory_if_exists(string packageName);

/// <summary>
/// Get outdated packages
/// </summary>
/// <param name="config">The configuration.</param>
ConcurrentDictionary<string, PackageResult> get_outdated(ChocolateyConfiguration config);
}
}
Loading

0 comments on commit 31fe5e3

Please sign in to comment.