by Nuget version
This commit is contained in:
@ -15,9 +15,9 @@ namespace isnd.Controllers
|
|||||||
public partial class PackagesController
|
public partial class PackagesController
|
||||||
{
|
{
|
||||||
// Web search
|
// Web search
|
||||||
public async Task<IActionResult> Index(PackageRegistrationIndexQuery model)
|
public async Task<IActionResult> Index(RegistrationPageIndexQuery model)
|
||||||
{
|
{
|
||||||
return View(packageManager.GetCatalogIndex());
|
return View(packageManager.GetPackageRegistrationIndex(model));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> Details(string pkgid)
|
public async Task<IActionResult> Details(string pkgid)
|
||||||
|
@ -1,20 +1,27 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace isnd.Data.Catalog
|
namespace isnd.Data.Catalog
|
||||||
{
|
{
|
||||||
public class PackageRegistrationIndexQuery : RegistrationPageIndex
|
public class RegistrationPageIndexQuery : RegistrationPageIndex
|
||||||
{
|
{
|
||||||
public PackageRegistrationIndexQuery(string id) : base(id)
|
|
||||||
|
public RegistrationPageIndexQuery() : base("")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public RegistrationPageIndexQuery(string bid, IEnumerable<RegistrationLeaf> leaves) : base(bid, leaves)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonProperty("prerelease")]
|
|
||||||
public bool Prerelease { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("query")]
|
[JsonProperty("query")]
|
||||||
public string Query { get; set; }
|
public string Query { get; set; }
|
||||||
|
|
||||||
[JsonProperty("totalHits")]
|
[JsonProperty("prerelease")]
|
||||||
public int TotalHits { get; internal set; }
|
public bool Prerelease { get; set; }
|
||||||
|
|
||||||
|
public int Skip { get; set; }
|
||||||
|
|
||||||
|
public int Take { get; set; } = 25;
|
||||||
|
public int TotalHits { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,6 +12,7 @@ namespace isnd.Data.Catalog
|
|||||||
public RegistrationPage (string id)
|
public RegistrationPage (string id)
|
||||||
{
|
{
|
||||||
Id = id;
|
Id = id;
|
||||||
|
Items = new List<RegistrationLeaf>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -54,7 +54,7 @@ namespace isnd.Data.Packages
|
|||||||
public RegistrationLeaf ToLeave(string bid)
|
public RegistrationLeaf ToLeave(string bid)
|
||||||
{
|
{
|
||||||
if (Versions.Count == 0) throw new Exception("NO VERSION");
|
if (Versions.Count == 0) throw new Exception("NO VERSION");
|
||||||
var v = Versions.OrderBy(w => w.SystemVersion).First();
|
var v = Versions.OrderBy(w => w.NugetVersion).First();
|
||||||
RegistrationLeaf leave = new RegistrationLeaf
|
RegistrationLeaf leave = new RegistrationLeaf
|
||||||
{
|
{
|
||||||
Id = bid + Id + "/" + v.FullString + ".json",
|
Id = bid + Id + "/" + v.FullString + ".json",
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
using System;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using isn.abst;
|
using isn.abst;
|
||||||
using isnd.Data.Packages;
|
using isnd.Data.Packages;
|
||||||
using isnd.Data.Packages.Catalog;
|
using isnd.Data.Packages.Catalog;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using NuGet.Versioning;
|
||||||
|
|
||||||
namespace isnd.Data
|
namespace isnd.Data
|
||||||
{
|
{
|
||||||
@ -53,7 +54,7 @@ namespace isnd.Data
|
|||||||
+ Constants.SpecFileEstension;
|
+ Constants.SpecFileEstension;
|
||||||
|
|
||||||
public string SementicVersionString { get => $"{Major}.{Minor}.{Patch}"; }
|
public string SementicVersionString { get => $"{Major}.{Minor}.{Patch}"; }
|
||||||
public Version SystemVersion { get => new Version(Major, Minor, Patch, Revision); }
|
public NuGetVersion NugetVersion { get => new NuGetVersion(FullString); }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,7 +19,6 @@ namespace isnd.Interfaces
|
|||||||
AutoCompleteResult AutoComplete(string pkgid, int skip, int take, bool prerelease = false, string packageType = null);
|
AutoCompleteResult AutoComplete(string pkgid, int skip, int take, bool prerelease = false, string packageType = null);
|
||||||
|
|
||||||
string[] GetVersions(string pkgid, NuGetVersion parsedVersion, bool prerelease = false, string packageType = null, int skip = 0, int take = 25);
|
string[] GetVersions(string pkgid, NuGetVersion parsedVersion, bool prerelease = false, string packageType = null, int skip = 0, int take = 25);
|
||||||
RegistrationPageIndex SearchByName(string query, int skip, int take, bool prerelease = false, string packageType = null);
|
|
||||||
IEnumerable<Resource> GetResources(IUnleash unleashĈlient);
|
IEnumerable<Resource> GetResources(IUnleash unleashĈlient);
|
||||||
void ÛpdateCatalogFor(Commit commit);
|
void ÛpdateCatalogFor(Commit commit);
|
||||||
Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type);
|
Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type);
|
||||||
@ -29,6 +28,7 @@ namespace isnd.Interfaces
|
|||||||
IEnumerable<RegistrationLeaf> SearchById(string pkgId, string semver, string pkgType);
|
IEnumerable<RegistrationLeaf> SearchById(string pkgId, string semver, string pkgType);
|
||||||
|
|
||||||
RegistrationPageIndex GetCatalogIndex();
|
RegistrationPageIndex GetCatalogIndex();
|
||||||
|
RegistrationPageIndexQuery GetPackageRegistrationIndex(RegistrationPageIndexQuery query);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -122,27 +122,6 @@ namespace isnd.Services
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RegistrationPageIndex SearchByName(string query,
|
|
||||||
int skip, int take, bool prerelease = false,
|
|
||||||
string packageType = null)
|
|
||||||
{
|
|
||||||
|
|
||||||
var scope = dbContext.Packages
|
|
||||||
.Include(p => p.Versions)
|
|
||||||
.Include(p => p.Owner)
|
|
||||||
.Where(
|
|
||||||
p => (PackageIdHelpers.CamelCaseMatch(p.Id, query) || PackageIdHelpers.SeparatedByMinusMatch(p.Id, query))
|
|
||||||
&& (prerelease || p.Versions.Any(v => !v.IsPrerelease))
|
|
||||||
&& (packageType == null || p.Versions.Any(v => v.Type == packageType))
|
|
||||||
);
|
|
||||||
var total = scope.Count();
|
|
||||||
var pkgs = scope.Skip(skip).Take(take).ToArray();
|
|
||||||
string bid = $"{extUrl}v3.4.0/{ApiConfig.Registration}/";
|
|
||||||
var leaves = pkgs.Select(p => p.ToLeave(bid));
|
|
||||||
|
|
||||||
return new RegistrationPageIndex(bid, leaves);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AutoCompleteResult AutoComplete(string id,
|
public AutoCompleteResult AutoComplete(string id,
|
||||||
int skip, int take, bool prerelease = false,
|
int skip, int take, bool prerelease = false,
|
||||||
string packageType = null)
|
string packageType = null)
|
||||||
@ -177,7 +156,7 @@ namespace isnd.Services
|
|||||||
&& (packageType == null || v.Type == packageType)
|
&& (packageType == null || v.Type == packageType)
|
||||||
&& (parsedVersion.CompareTo(new SemanticVersion(v.Major, v.Minor, v.Patch)) < 0)
|
&& (parsedVersion.CompareTo(new SemanticVersion(v.Major, v.Minor, v.Patch)) < 0)
|
||||||
)
|
)
|
||||||
.OrderBy(v => v.FullString)
|
.OrderBy(v => v.NugetVersion)
|
||||||
.Select(v => v.FullString)
|
.Select(v => v.FullString)
|
||||||
.Skip(skip).Take(take).ToArray();
|
.Skip(skip).Take(take).ToArray();
|
||||||
}
|
}
|
||||||
@ -234,6 +213,7 @@ namespace isnd.Services
|
|||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
var validPkgs = dbContext.Packages
|
var validPkgs = dbContext.Packages
|
||||||
|
.Include(po => po.Owner)
|
||||||
.Include(pkg => pkg.Versions)
|
.Include(pkg => pkg.Versions)
|
||||||
.Include(pkg => pkg.LatestVersion)
|
.Include(pkg => pkg.LatestVersion)
|
||||||
.Where(
|
.Where(
|
||||||
@ -319,8 +299,6 @@ namespace isnd.Services
|
|||||||
&& (pkgType == null || pkgType == v.Type));
|
&& (pkgType == null || pkgType == v.Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public async Task<PackageDeletionReport> UserAskForPackageDeletionAsync(string uid, string id, string lower, string type)
|
public async Task<PackageDeletionReport> UserAskForPackageDeletionAsync(string uid, string id, string lower, string type)
|
||||||
{
|
{
|
||||||
PackageVersion packageVersion = await dbContext.PackageVersions
|
PackageVersion packageVersion = await dbContext.PackageVersions
|
||||||
@ -337,6 +315,7 @@ namespace isnd.Services
|
|||||||
string bid = $"{extUrl}v3.4.0/{ApiConfig.Registration}/";
|
string bid = $"{extUrl}v3.4.0/{ApiConfig.Registration}/";
|
||||||
return dbContext.PackageVersions
|
return dbContext.PackageVersions
|
||||||
.Include(v => v.Package)
|
.Include(v => v.Package)
|
||||||
|
.Include(v => v.Package.Owner)
|
||||||
.Include(v => v.LatestCommit)
|
.Include(v => v.LatestCommit)
|
||||||
.Where(v => v.PackageId == pkgId && semver.StartsWith(v.SementicVersionString)
|
.Where(v => v.PackageId == pkgId && semver.StartsWith(v.SementicVersionString)
|
||||||
&& (pkgType == null || pkgType == v.Type)).Select(p => p.Package.ToLeave(bid));
|
&& (pkgType == null || pkgType == v.Type)).Select(p => p.Package.ToLeave(bid));
|
||||||
@ -349,5 +328,25 @@ namespace isnd.Services
|
|||||||
.Single(v => v.PackageId == pkgId && semver == v.FullString
|
.Single(v => v.PackageId == pkgId && semver == v.FullString
|
||||||
&& (pkgType == null || pkgType == v.Type));
|
&& (pkgType == null || pkgType == v.Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RegistrationPageIndexQuery GetPackageRegistrationIndex(RegistrationPageIndexQuery query)
|
||||||
|
{
|
||||||
|
// RegistrationPageIndexAndQuery
|
||||||
|
var scope = dbContext.Packages
|
||||||
|
.Include(p => p.Versions)
|
||||||
|
.Include(p => p.Owner)
|
||||||
|
.Where(
|
||||||
|
p => (PackageIdHelpers.CamelCaseMatch(p.Id, query.Query)
|
||||||
|
|| PackageIdHelpers.SeparatedByMinusMatch(p.Id, query.Query))
|
||||||
|
&& (query.Prerelease || p.Versions.Any(v => !v.IsPrerelease))
|
||||||
|
);
|
||||||
|
var total = scope.Count();
|
||||||
|
var pkgs = scope.Skip(query.Skip).Take(query.Take).ToArray();
|
||||||
|
string bid = $"{extUrl}v3.4.0/{ApiConfig.Registration}/";
|
||||||
|
var leaves = pkgs.Select(p => p.ToLeave(bid));
|
||||||
|
|
||||||
|
return
|
||||||
|
new RegistrationPageIndexQuery(bid, leaves);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
@model PackageRegistrationIndexQuery
|
@model RegistrationPageIndexQuery
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Index";
|
ViewData["Title"] = "Index";
|
||||||
|
Reference in New Issue
Block a user