Commit Id and TimerStamps
This commit is contained in:
@ -1,10 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using isnd.Data;
|
||||
using isnd.Data.ApiKeys;
|
||||
using isnd.Data.Packages;
|
||||
|
||||
@ -22,6 +17,17 @@ namespace isnd.Data
|
||||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
|
||||
: base(options) { }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
_ = builder.Entity<PackageVersion>()
|
||||
.HasKey( v => new { v.PackageId, v.FullString } );
|
||||
_ = builder.Entity<PackageVersion>()
|
||||
.HasOne(v => v.Package).WithMany(p => p.Versions).HasForeignKey(x => x.PackageId);
|
||||
// _ = builder.Entity<Package>().HasMany(p => p.Versions).WithOne(V => V.Package).HasForeignKey(x => new { x.PackageId, x.FullString });
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// User API keys
|
||||
/// </summary>
|
||||
@ -33,7 +39,7 @@ namespace isnd.Data
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public DbSet<Package> Packages { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Package Versions
|
||||
/// </summary>
|
||||
|
@ -22,6 +22,9 @@ namespace isnd.Data.Catalog
|
||||
Version = pkg.FullString;
|
||||
authors = $"{pkg.Package.Owner.FullName} <${pkg.Package.Owner.Email}>";
|
||||
packageContent = apiBase + pkg.NugetLink;
|
||||
CommitId = pkg.CommitId;
|
||||
CommitTimeStamp = pkg.LatestCommit.CommitTimeStamp;
|
||||
|
||||
}
|
||||
|
||||
[JsonProperty("@type")]
|
||||
|
@ -20,11 +20,8 @@ namespace isnd.Data.Catalog
|
||||
{
|
||||
new CatalogPage(bid, pkg.Id, apiBase, pkg.Versions)
|
||||
};
|
||||
|
||||
|
||||
CommitId = pkg.LatestCommit.CommitId;
|
||||
CommitTimeStamp = pkg.LatestCommit.CommitTimeStamp;
|
||||
|
||||
}
|
||||
|
||||
[JsonProperty("count")]
|
||||
|
@ -2,9 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Data.Packages.Catalog;
|
||||
using isnd.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@ -24,7 +21,7 @@ namespace isnd.Data.Packages
|
||||
DateTimeOffset CommitTimeStamp { get; set; }
|
||||
}
|
||||
|
||||
public class Package : IObject, IPackage
|
||||
public class Package
|
||||
{
|
||||
[Key]
|
||||
[Required]
|
||||
@ -53,16 +50,16 @@ namespace isnd.Data.Packages
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[Required]
|
||||
[JsonIgnore]
|
||||
[JsonIgnore]
|
||||
[ForeignKey("LatestCommit")]
|
||||
public long CommitNId { get; set; }
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public string CommitId { get => CommitNId.ToString(); }
|
||||
|
||||
[ForeignKey("CommitNId")]
|
||||
|
||||
public virtual Commit LatestCommit { get; set; }
|
||||
public DateTimeOffset CommitTimeStamp { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
using System.Security.Principal;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
@ -13,7 +14,7 @@ using NuGet.Versioning;
|
||||
namespace isnd.Data
|
||||
{
|
||||
[PrimaryKey("PackageId", "FullString")]
|
||||
public class PackageVersion
|
||||
public class PackageVersion
|
||||
{
|
||||
[Required]
|
||||
[ForeignKey("Package")]
|
||||
|
Reference in New Issue
Block a user