WIP page leaf
This commit is contained in:
parent
2dcf1a2806
commit
7f9984b059
28 changed files with 164 additions and 75 deletions
|
|
@ -1,6 +1,5 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Helpers;
|
||||
using isnd.Services;
|
||||
using isnd.Entities;
|
||||
|
|
@ -20,7 +19,7 @@ namespace isnd.Controllers
|
|||
{
|
||||
return Ok(PackageManager.CurrentCatalogIndex);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogPage + "-{id}")]
|
||||
public IActionResult Index(string id)
|
||||
{
|
||||
|
|
@ -28,21 +27,20 @@ namespace isnd.Controllers
|
|||
return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]);
|
||||
}
|
||||
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Registration + "/{id}/{*lower}")]
|
||||
public async Task<IActionResult> CatalogRegistrationAsync(string id, string lower)
|
||||
[HttpGet(_pkgRootPrefix + "{apiVersion}/" + ApiConfig.Registration + "/{id}/{*lower}")]
|
||||
public async Task<IActionResult> CatalogRegistrationAsync(string apiVersion, string id, string lower)
|
||||
{
|
||||
bool askForindex = lower != null && lower.EndsWith(ApiConfig.Base);
|
||||
if (askForindex)
|
||||
{
|
||||
lower = lower.Substring(0, lower.Length - ApiConfig.Base.Length);
|
||||
}
|
||||
string pkgType = ParamHelpers.Optional(ref lower);
|
||||
var pkgVersion = await dbContext.PackageVersions
|
||||
.Include(v => v.LatestCommit)
|
||||
.SingleOrDefaultAsync(
|
||||
v => v.PackageId == id &&
|
||||
v.FullString == lower &&
|
||||
v.Type == pkgType
|
||||
);
|
||||
if (pkgVersion == null) return NotFound();
|
||||
return Ok();
|
||||
}
|
||||
|
||||
var pkgFromname = packageManager.SearchByName(id, 0, 1);
|
||||
if (pkgFromname == null) return NotFound();
|
||||
return Ok(pkgFromname);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{version}/{*lower}")]
|
||||
public async Task<IActionResult> CatalogLeafAsync(string id, string version, string lower)
|
||||
|
|
@ -50,25 +48,27 @@ namespace isnd.Controllers
|
|||
var pkgvs = this.packageManager.GetCatalogLeaf(id, version, lower)
|
||||
.ToArray();
|
||||
|
||||
if (pkgvs.Count()==0) return NotFound();
|
||||
if (pkgvs.Count() == 0) return NotFound();
|
||||
|
||||
List <string> types = pkgvs.Select(
|
||||
List<string> types = pkgvs.Select(
|
||||
v => v.Type ?? "Dependency"
|
||||
).Distinct().ToList();
|
||||
if (!types.Contains("PackageDelete"))
|
||||
types.Add("PackageDetails");
|
||||
var pub = pkgvs.Last().Package.CommitTimeStamp;
|
||||
types.Add("PackageDetails");
|
||||
|
||||
var last = pkgvs.Last();
|
||||
var pub = last.Package.CommitTimeStamp;
|
||||
var firstpub = pkgvs.First().Package.CommitTimeStamp;
|
||||
|
||||
return Ok(new CatalogLeaf
|
||||
return Ok(new Data.Packages.Catalog.CatalogLeaf
|
||||
{
|
||||
CommitId = id,
|
||||
CommitId = last.CommitId,
|
||||
Id = id,
|
||||
CommitTimeStamp = firstpub,
|
||||
Version = version,
|
||||
CommitTimeStamp = pub,
|
||||
Version = last.FullString,
|
||||
Published = pub,
|
||||
RefType = types.ToArray(),
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue