refacts
This commit is contained in:
parent
a84e1d9750
commit
2dcf1a2806
18 changed files with 166 additions and 98 deletions
|
|
@ -6,6 +6,7 @@ using isnd.Services;
|
|||
using isnd.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
|
|
@ -27,8 +28,8 @@ namespace isnd.Controllers
|
|||
return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]);
|
||||
}
|
||||
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{*lower}")]
|
||||
public async Task<IActionResult> CatalogLeafAsync(string id, string lower)
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Registration + "/{id}/{*lower}")]
|
||||
public async Task<IActionResult> CatalogRegistrationAsync(string id, string lower)
|
||||
{
|
||||
string pkgType = ParamHelpers.Optional(ref lower);
|
||||
var pkgVersion = await dbContext.PackageVersions
|
||||
|
|
@ -39,21 +40,35 @@ namespace isnd.Controllers
|
|||
v.Type == pkgType
|
||||
);
|
||||
if (pkgVersion == null) return NotFound();
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{version}/{*lower}")]
|
||||
public async Task<IActionResult> CatalogLeafAsync(string id, string version, string lower)
|
||||
{
|
||||
var pkgvs = this.packageManager.GetCatalogLeaf(id, version, lower)
|
||||
.ToArray();
|
||||
|
||||
if (pkgvs.Count()==0) return NotFound();
|
||||
|
||||
List <string> types = pkgvs.Select(
|
||||
v => v.Type ?? "Dependency"
|
||||
).Distinct().ToList();
|
||||
if (!types.Contains("PackageDelete"))
|
||||
types.Add("PackageDetails");
|
||||
var pub = pkgvs.Last().Package.CommitTimeStamp;
|
||||
var firstpub = pkgvs.First().Package.CommitTimeStamp;
|
||||
|
||||
var pub = await dbContext.Commits
|
||||
.Include(c => c.Versions)
|
||||
.OrderBy(c => c.CommitTimeStamp)
|
||||
.SingleOrDefaultAsync
|
||||
(
|
||||
c => c.Action == PackageAction.PublishPackage
|
||||
&& c.Versions.Contains(pkgVersion)
|
||||
);
|
||||
return Ok(new CatalogLeaf
|
||||
{
|
||||
CommitId = id,
|
||||
Id = pkgVersion.PackageId,
|
||||
CommitTimeStamp = pkgVersion.LatestCommit.CommitTimeStamp
|
||||
|
||||
Id = id,
|
||||
CommitTimeStamp = firstpub,
|
||||
Version = version,
|
||||
Published = pub,
|
||||
RefType = types.ToArray(),
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue