unit tests and pkg version commits
This commit is contained in:
@ -14,12 +14,12 @@ using Unleash;
|
||||
|
||||
namespace isnd.Services
|
||||
{
|
||||
|
||||
|
||||
|
||||
public class PackageManager : IPackageManager
|
||||
{
|
||||
ApplicationDbContext dbContext;
|
||||
public PackageManager(ApplicationDbContext dbContext,
|
||||
public PackageManager(ApplicationDbContext dbContext,
|
||||
IOptions<IsndSettings> siteConfigOptionsOptions)
|
||||
{
|
||||
this.dbContext = dbContext;
|
||||
@ -55,10 +55,6 @@ namespace isnd.Services
|
||||
|
||||
public CatalogIndex GenerateCatalogIndex(string commitId)
|
||||
{
|
||||
|
||||
var root = "/index.json";
|
||||
|
||||
|
||||
var catalog = new CatalogIndex
|
||||
{
|
||||
CommitId = commitId,
|
||||
@ -155,13 +151,13 @@ namespace isnd.Services
|
||||
}
|
||||
void LoadCatalogFromDb()
|
||||
{
|
||||
int i=0;
|
||||
int p=0;
|
||||
int i = 0;
|
||||
int p = 0;
|
||||
var oldIndex = CurrentCatalogIndex;
|
||||
var oldPages = CurrentCatalogPages;
|
||||
CurrentCatalogIndex = new CatalogIndex
|
||||
{
|
||||
|
||||
|
||||
};
|
||||
CurrentCatalogPages = new List<Page>();
|
||||
|
||||
@ -169,46 +165,60 @@ namespace isnd.Services
|
||||
Commit last = null;
|
||||
PageRef pageRef = null;
|
||||
Page page = null;
|
||||
i=pmConfigOptions.CatalogPageLen;
|
||||
i = pmConfigOptions.CatalogPageLen;
|
||||
foreach (var commit in scope)
|
||||
{
|
||||
if (i >= this.pmConfigOptions.CatalogPageLen)
|
||||
{
|
||||
page = new Page{
|
||||
Parent = pmConfigOptions.ExternalUrl + "/package",
|
||||
page = new Page
|
||||
{
|
||||
Parent = pmConfigOptions.ExternalUrl + "/package",
|
||||
CommitId = commit.CommitId,
|
||||
CommitTimeStamp = commit.CommitTimeStamp,
|
||||
Id = this.pmConfigOptions.ExternalUrl + "/package/index-" + p++
|
||||
|
||||
};
|
||||
CurrentCatalogPages.Add(page);
|
||||
pageRef = new PageRef{
|
||||
Id = page.Id
|
||||
pageRef = new PageRef
|
||||
{
|
||||
Id = page.Id
|
||||
};
|
||||
CurrentCatalogIndex.Items.Add(pageRef);
|
||||
i = 0;
|
||||
}
|
||||
PackageRef packageref = new PackageRef
|
||||
var validPkgs = dbContext.Packages
|
||||
.Include(pkg => pkg.Versions)
|
||||
.Where(
|
||||
pkg => pkg.Versions.Count() > 0
|
||||
);
|
||||
// pkg.Versions.OrderByDescending(vi => vi.CommitNId).First().FullString
|
||||
foreach (var pkg in validPkgs)
|
||||
{
|
||||
CommitId = commit.Id.ToString(),
|
||||
Id = commit.PackageVersionId,
|
||||
|
||||
var v = pkg.Versions.OrderByDescending(vc => vc.CommitNId).First();
|
||||
|
||||
CommitTimeStamp = commit.CommitTimeStamp,
|
||||
RefType = commit.Action == PackageAction.PublishPackage ?
|
||||
"nuget:PackageDetails" : "nuget:PackageDelete"
|
||||
};
|
||||
|
||||
page.Items.Add(packageref);
|
||||
var pkgref = new PackageRef
|
||||
{
|
||||
Version = v.FullString,
|
||||
LastCommit = v.LatestCommit,
|
||||
CommitId = v.LatestCommit.CommitId,
|
||||
CommitTimeStamp = v.LatestCommit.CommitTimeStamp,
|
||||
RefId = page.Id,
|
||||
Id = v.PackageId
|
||||
};
|
||||
page.Items.Add(pkgref);
|
||||
}
|
||||
last = commit;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (last!=null)
|
||||
if (last != null)
|
||||
{
|
||||
CurrentCatalogIndex.CommitId = last.CommitId;
|
||||
}
|
||||
throw new NotImplementedException();
|
||||
else
|
||||
{
|
||||
CurrentCatalogIndex.CommitId = "none";
|
||||
}
|
||||
}
|
||||
|
||||
protected static bool CamelCaseMatch(string id, string query)
|
||||
|
Reference in New Issue
Block a user