|
|
|
@ -20,6 +20,8 @@ using System.Xml;
|
|
|
|
using System.Xml.Linq;
|
|
|
|
using System.Xml.Linq;
|
|
|
|
using NuGet.Protocol;
|
|
|
|
using NuGet.Protocol;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
|
|
namespace isnd.Services
|
|
|
|
namespace isnd.Services
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -29,11 +31,13 @@ namespace isnd.Services
|
|
|
|
readonly ApplicationDbContext dbContext;
|
|
|
|
readonly ApplicationDbContext dbContext;
|
|
|
|
|
|
|
|
|
|
|
|
public PackageManager(ApplicationDbContext dbContext,
|
|
|
|
public PackageManager(ApplicationDbContext dbContext,
|
|
|
|
IOptions<IsndSettings> siteConfigOptionsOptions)
|
|
|
|
IOptions<IsndSettings> siteConfigOptionsOptions,
|
|
|
|
|
|
|
|
ILoggerFactory loggerFactory)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.dbContext = dbContext;
|
|
|
|
this.dbContext = dbContext;
|
|
|
|
isndSettings = siteConfigOptionsOptions.Value;
|
|
|
|
isndSettings = siteConfigOptionsOptions.Value;
|
|
|
|
apiBase = isndSettings.ExternalUrl + Constants.ApiVersionPrefix;
|
|
|
|
apiBase = isndSettings.ExternalUrl + Constants.ApiVersionPrefix;
|
|
|
|
|
|
|
|
this.logger = loggerFactory.CreateLogger<PackageManager>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IEnumerable<Resource> GetResources()
|
|
|
|
public IEnumerable<Resource> GetResources()
|
|
|
|
@ -173,6 +177,7 @@ namespace isnd.Services
|
|
|
|
|
|
|
|
|
|
|
|
private IsndSettings isndSettings;
|
|
|
|
private IsndSettings isndSettings;
|
|
|
|
private readonly string apiBase;
|
|
|
|
private readonly string apiBase;
|
|
|
|
|
|
|
|
private readonly ILogger<PackageManager> logger;
|
|
|
|
|
|
|
|
|
|
|
|
public virtual async Task<Catalog> GetCatalogIndexAsync()
|
|
|
|
public virtual async Task<Catalog> GetCatalogIndexAsync()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -357,6 +362,8 @@ namespace isnd.Services
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<PackageSearchResult> SearchPackageAsync(PackageRegistrationQuery query)
|
|
|
|
public async Task<PackageSearchResult> SearchPackageAsync(PackageRegistrationQuery query)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Debug.Assert(query != null);
|
|
|
|
|
|
|
|
logger.LogInformation(query.ToString());
|
|
|
|
string bid = $"{apiBase}{ApiConfig.Registration}";
|
|
|
|
string bid = $"{apiBase}{ApiConfig.Registration}";
|
|
|
|
if (string.IsNullOrWhiteSpace(query.Query))
|
|
|
|
if (string.IsNullOrWhiteSpace(query.Query))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -371,9 +378,11 @@ namespace isnd.Services
|
|
|
|
.Where(p => p.Versions.Count >= 0);
|
|
|
|
.Where(p => p.Versions.Count >= 0);
|
|
|
|
|
|
|
|
|
|
|
|
var count = await allPackages.CountAsync();
|
|
|
|
var count = await allPackages.CountAsync();
|
|
|
|
|
|
|
|
logger.LogInformation($" total hits : {count}");
|
|
|
|
|
|
|
|
|
|
|
|
var packages = await allPackages
|
|
|
|
var packages = await allPackages
|
|
|
|
.Skip(query.Skip).Take(query.Take).ToArrayAsync();
|
|
|
|
.Skip(query.Skip).Take(query.Take).ToArrayAsync();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var package in packages)
|
|
|
|
foreach (var package in packages)
|
|
|
|
foreach (var version in package.Versions)
|
|
|
|
foreach (var version in package.Versions)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -381,6 +390,7 @@ namespace isnd.Services
|
|
|
|
.Where(d => d.PackageVersionFullString == version.FullString && d.PackageId == version.PackageId)
|
|
|
|
.Where(d => d.PackageVersionFullString == version.FullString && d.PackageId == version.PackageId)
|
|
|
|
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
logger.LogInformation($" version: {version.PackageId} {version.FullString} {version.DependencyGroups.Count}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new PackageSearchResult(packages, apiBase, count);
|
|
|
|
return new PackageSearchResult(packages, apiBase, count);
|
|
|
|
|