Searching deleted package
This commit is contained in:
@ -18,8 +18,13 @@ namespace isnd.Controllers
|
||||
// Web search
|
||||
public async Task<IActionResult> Index(PackageRegistrationQuery model)
|
||||
{
|
||||
return View(new RegistrationPageIndexQueryAndResult{Query = model,
|
||||
Result = await packageManager.SearchPackageAsync(model)});
|
||||
var pkgs = await packageManager.SearchPackageAsync(model);
|
||||
|
||||
return View(new RegistrationPageIndexQueryAndResult
|
||||
{
|
||||
Query = model,
|
||||
Result = pkgs.ToArray()
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Details(PackageDetailViewModel model)
|
||||
@ -30,6 +35,7 @@ namespace isnd.Controllers
|
||||
}
|
||||
|
||||
var packageVersion = dbContext.PackageVersions
|
||||
.Include(p=>p.LatestCommit)
|
||||
.Include(p => p.Package)
|
||||
.Where(m => m.PackageId == model.pkgid)
|
||||
.OrderByDescending(p => p)
|
||||
@ -48,7 +54,7 @@ namespace isnd.Controllers
|
||||
}
|
||||
const int MAX_PKG_VERSION_LIST = 50;
|
||||
|
||||
[Authorize]
|
||||
[Authorize, HttpGet]
|
||||
public async Task<IActionResult> Delete(string pkgid, string version, string pkgtype)
|
||||
{
|
||||
if (pkgid == null || version == null)
|
||||
@ -66,7 +72,7 @@ namespace isnd.Controllers
|
||||
}
|
||||
|
||||
// POST: PackageVersion/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(string PackageId, string FullString,
|
||||
string Type)
|
||||
|
@ -14,31 +14,17 @@ namespace isnd.Data.Catalog
|
||||
Items = new List<CatalogPage>();
|
||||
}
|
||||
|
||||
public PackageRegistration(string bid, string id, string apiBase, IEnumerable<Packages.Package> pkgs) : base(bid + $"/{id}/index.json")
|
||||
public PackageRegistration(string bid, string id, string apiBase, Packages.Package pkg) : base(bid + $"/{id}/index.json")
|
||||
{
|
||||
Items = new List<CatalogPage>();
|
||||
long cnid = 0;
|
||||
var pkgsGroups = pkgs.GroupBy(l => l.Id);
|
||||
// Pour tous les groupes par Id
|
||||
foreach (var gsp in pkgsGroups)
|
||||
Items = new List<CatalogPage>
|
||||
{
|
||||
var pkgsbi = gsp.ToArray();
|
||||
List<PackageVersion> versions = new List<PackageVersion>();
|
||||
|
||||
foreach(var l in pkgsbi.Select(p => p.Versions))
|
||||
{
|
||||
versions.AddRange(l);
|
||||
foreach (var pv in l)
|
||||
{
|
||||
if (pv.CommitNId> cnid)
|
||||
{
|
||||
cnid = pv.CommitNId;
|
||||
}
|
||||
}
|
||||
}
|
||||
Items.Add(new CatalogPage(bid, gsp.Key, apiBase, versions));
|
||||
new CatalogPage(bid, id, apiBase, pkg.Versions)
|
||||
};
|
||||
if (pkg.Versions.Count>0)
|
||||
{
|
||||
CommitId = pkg.Versions.Max(v=>v.CommitNId).ToString();
|
||||
CommitTimeStamp = pkg.Versions.Max(v=>v.LatestCommit.CommitTimeStamp);
|
||||
}
|
||||
CommitId = cnid.ToString();
|
||||
}
|
||||
|
||||
[JsonProperty("count")]
|
||||
@ -49,5 +35,7 @@ namespace isnd.Data.Catalog
|
||||
|
||||
public string CommitId { get; set; }
|
||||
public DateTimeOffset CommitTimeStamp { get; internal set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -76,5 +76,6 @@ namespace isnd.Data
|
||||
}
|
||||
);
|
||||
}
|
||||
public bool IsDeleted => LatestCommit.Action == PackageAction.DeletePackage;
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ namespace isnd.Interfaces
|
||||
Task<PackageRegistration> GetCatalogIndexAsync();
|
||||
Task<PackageRegistration> GetPackageRegistrationIndexAsync(PackageRegistrationQuery query);
|
||||
|
||||
Task<PackageRegistration> SearchPackageAsync(PackageRegistrationQuery query);
|
||||
Task<IEnumerable<PackageRegistration>> SearchPackageAsync(PackageRegistrationQuery query);
|
||||
}
|
||||
|
||||
}
|
@ -194,7 +194,7 @@ namespace isnd.Services
|
||||
var commit = new Commit
|
||||
{
|
||||
Action = PackageAction.DeletePackage,
|
||||
TimeStamp = DateTime.Now
|
||||
TimeStamp = DateTimeOffset.Now.ToUniversalTime()
|
||||
};
|
||||
dbContext.Commits.Add(commit);
|
||||
var pkg = await dbContext.PackageVersions.SingleOrDefaultAsync(
|
||||
@ -276,13 +276,13 @@ namespace isnd.Services
|
||||
query.Query = query.Query.ToLower();
|
||||
var scope = await dbContext.Packages.Include(p => p.Versions).Include(p => p.Owner)
|
||||
.Include(p=>p.LatestVersion)
|
||||
.Where(p => p.Id.ToLower() == query.Query).Skip(query.Skip).Take(query.Take).ToListAsync();
|
||||
|
||||
.SingleAsync(p => p.Id.ToLower() == query.Query);
|
||||
if (scope.Versions.Count==0) return null;
|
||||
string bid = $"{apiBase}{ApiConfig.Registration}";
|
||||
return
|
||||
new PackageRegistration(bid, query.Query, apiBase, scope);
|
||||
}
|
||||
public async Task<PackageRegistration> SearchPackageAsync(PackageRegistrationQuery query)
|
||||
public async Task<IEnumerable<PackageRegistration>> SearchPackageAsync(PackageRegistrationQuery query)
|
||||
{
|
||||
string bid = $"{apiBase}{ApiConfig.Registration}";
|
||||
|
||||
@ -297,8 +297,7 @@ namespace isnd.Services
|
||||
var total = scope.Count();
|
||||
var pkgs = scope.Skip(query.Skip).Take(query.Take);
|
||||
|
||||
return
|
||||
new PackageRegistration(bid, query.Query, apiBase, pkgs);
|
||||
return pkgs.Select(p => new PackageRegistration(bid, query.Query, apiBase, p));
|
||||
}
|
||||
|
||||
private static bool MatchingExact(Data.Packages.Package p, PackageRegistrationQuery query)
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using isnd.Data.Catalog;
|
||||
|
||||
namespace isnd
|
||||
@ -5,6 +6,6 @@ namespace isnd
|
||||
public class RegistrationPageIndexQueryAndResult
|
||||
{
|
||||
public PackageRegistrationQuery Query { get; set; }
|
||||
public PackageRegistration Result { get; set; }
|
||||
public PackageRegistration[] Result { get; set; }
|
||||
}
|
||||
}
|
@ -43,7 +43,7 @@
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<form asp-action="Delete">
|
||||
<form asp-action="DeleteConfirmed">
|
||||
<input type="hidden" asp-for="PackageId" />
|
||||
<input type="hidden" asp-for="FullString" />
|
||||
<input type="hidden" asp-for="Type" />
|
||||
|
@ -10,25 +10,26 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Result.Items[0].Items[0].Id)
|
||||
@Html.DisplayNameFor(model => model.Result[0].Items[0].Items[0].Id)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Result.Items[0].Items[0].Entry.Description)
|
||||
@Html.DisplayNameFor(model => model.Result[0].Items[0].Items[0].Entry.Description)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var regpage in Model.Result.Items) {
|
||||
@foreach (var regpage in Model.Result)
|
||||
foreach (var i in regpage.Items) {
|
||||
<tr>
|
||||
<td>
|
||||
@regpage.GetPackageId()
|
||||
@i.GetPackageId()
|
||||
</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
@Html.ActionLink("Details", "Details", new { pkgid = regpage.GetPackageId() })
|
||||
@Html.ActionLink("Details", "Details", new { pkgid = i.GetPackageId() })
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
Reference in New Issue
Block a user