add remainder of seed data

This commit is contained in:
Collin M. Barrett 2018-01-18 05:35:37 -06:00
parent 7a81cc202f
commit 772372b1ad
10 changed files with 2492 additions and 14 deletions

View file

@ -29,11 +29,29 @@ public static bool AllMigrationsApplied(this DbContext context)
public static void EnsureSeeded(this FilterListsDbContext context)
{
SeedEntities(context);
SeedJunctions(context);
}
private static void SeedEntities(FilterListsDbContext context)
{
SeedLanguages(context);
SeedLicenses(context);
SeedMaintainers(context);
SeedSoftware(context);
SeedSyntaxes(context);
SeedFilterLists(context);
}
private static void SeedJunctions(FilterListsDbContext context)
{
SeedFilterListLanguages(context);
SeedFilterListMaintainers(context);
SeedForks(context);
SeedMerges(context);
SeedSoftwareSyntaxes(context);
}
//TODO: fix generic method to remove duplication of entity-specific methods
private static void Seed<T>(DbContext context)
{
@ -44,6 +62,26 @@ private static void Seed<T>(DbContext context)
context.SaveChanges();
}
#region Entities
private static void SeedFilterLists(FilterListsDbContext context)
{
if (context.FilterLists.Any()) return;
var types = JsonConvert.DeserializeObject<List<FilterList>>(
File.ReadAllText(SeedDirectory + Path.DirectorySeparatorChar + typeof(FilterList).Name + ".json"));
context.AddRange(types);
context.SaveChanges();
}
private static void SeedLanguages(FilterListsDbContext context)
{
if (context.Languages.Any()) return;
var types = JsonConvert.DeserializeObject<List<Language>>(
File.ReadAllText(SeedDirectory + Path.DirectorySeparatorChar + typeof(Language).Name + ".json"));
context.AddRange(types);
context.SaveChanges();
}
private static void SeedLicenses(FilterListsDbContext context)
{
if (context.Licenses.Any()) return;
@ -53,6 +91,24 @@ private static void SeedLicenses(FilterListsDbContext context)
context.SaveChanges();
}
private static void SeedMaintainers(FilterListsDbContext context)
{
if (context.Maintainers.Any()) return;
var types = JsonConvert.DeserializeObject<List<Maintainer>>(
File.ReadAllText(SeedDirectory + Path.DirectorySeparatorChar + typeof(Maintainer).Name + ".json"));
context.AddRange(types);
context.SaveChanges();
}
private static void SeedSoftware(FilterListsDbContext context)
{
if (context.Software.Any()) return;
var types = JsonConvert.DeserializeObject<List<Software>>(
File.ReadAllText(SeedDirectory + Path.DirectorySeparatorChar + typeof(Software).Name + ".json"));
context.AddRange(types);
context.SaveChanges();
}
private static void SeedSyntaxes(FilterListsDbContext context)
{
if (context.Syntaxes.Any()) return;
@ -62,13 +118,57 @@ private static void SeedSyntaxes(FilterListsDbContext context)
context.SaveChanges();
}
private static void SeedFilterLists(FilterListsDbContext context)
#endregion
#region Junctions
private static void SeedFilterListLanguages(FilterListsDbContext context)
{
if (context.FilterLists.Any()) return;
var types = JsonConvert.DeserializeObject<List<FilterList>>(
File.ReadAllText(SeedDirectory + Path.DirectorySeparatorChar + typeof(FilterList).Name + ".json"));
if (context.FilterListLanguages.Any()) return;
var types = JsonConvert.DeserializeObject<List<FilterListLanguage>>(
File.ReadAllText(
SeedDirectory + Path.DirectorySeparatorChar + typeof(FilterListLanguage).Name + ".json"));
context.AddRange(types);
context.SaveChanges();
}
private static void SeedFilterListMaintainers(FilterListsDbContext context)
{
if (context.FilterListMaintainers.Any()) return;
var types = JsonConvert.DeserializeObject<List<FilterListMaintainer>>(
File.ReadAllText(SeedDirectory + Path.DirectorySeparatorChar + typeof(FilterListMaintainer).Name +
".json"));
context.AddRange(types);
context.SaveChanges();
}
private static void SeedForks(FilterListsDbContext context)
{
if (context.Forks.Any()) return;
var types = JsonConvert.DeserializeObject<List<Fork>>(
File.ReadAllText(SeedDirectory + Path.DirectorySeparatorChar + typeof(Fork).Name + ".json"));
context.AddRange(types);
context.SaveChanges();
}
private static void SeedMerges(FilterListsDbContext context)
{
if (context.Merges.Any()) return;
var types = JsonConvert.DeserializeObject<List<Merge>>(
File.ReadAllText(SeedDirectory + Path.DirectorySeparatorChar + typeof(Merge).Name + ".json"));
context.AddRange(types);
context.SaveChanges();
}
private static void SeedSoftwareSyntaxes(FilterListsDbContext context)
{
if (context.SoftwareSyntaxes.Any()) return;
var types = JsonConvert.DeserializeObject<List<SoftwareSyntax>>(
File.ReadAllText(SeedDirectory + Path.DirectorySeparatorChar + typeof(SoftwareSyntax).Name + ".json"));
context.AddRange(types);
context.SaveChanges();
}
#endregion
}
}

View file

@ -0,0 +1,22 @@
[
{
"ForkFilterListId": 7,
"UpstreamFilterListId": 9
},
{
"ForkFilterListId": 8,
"UpstreamFilterListId": 9
},
{
"ForkFilterListId": 16,
"UpstreamFilterListId": 59
},
{
"ForkFilterListId": 16,
"UpstreamFilterListId": 99
},
{
"ForkFilterListId": 16,
"UpstreamFilterListId": 278
}
]

View file

@ -0,0 +1,30 @@
[
{
"FilterListId": 20,
"LanguageId": 44
},
{
"FilterListId": 14,
"LanguageId": 122
},
{
"FilterListId": 1,
"LanguageId": 141
},
{
"FilterListId": 6,
"LanguageId": 141
},
{
"FilterListId": 15,
"LanguageId": 154
},
{
"FilterListId": 16,
"LanguageId": 154
},
{
"FilterListId": 12,
"LanguageId": 163
}
]

View file

@ -0,0 +1,170 @@
[
{
"FilterListId": 1,
"MaintainerId": 2
},
{
"FilterListId": 2,
"MaintainerId": 3
},
{
"FilterListId": 3,
"MaintainerId": 4
},
{
"FilterListId": 4,
"MaintainerId": 5
},
{
"FilterListId": 5,
"MaintainerId": 6
},
{
"FilterListId": 6,
"MaintainerId": 8
},
{
"FilterListId": 7,
"MaintainerId": 9
},
{
"FilterListId": 8,
"MaintainerId": 9
},
{
"FilterListId": 9,
"MaintainerId": 9
},
{
"FilterListId": 10,
"MaintainerId": 10
},
{
"FilterListId": 12,
"MaintainerId": 11
},
{
"FilterListId": 12,
"MaintainerId": 12
},
{
"FilterListId": 14,
"MaintainerId": 12
},
{
"FilterListId": 12,
"MaintainerId": 13
},
{
"FilterListId": 14,
"MaintainerId": 13
},
{
"FilterListId": 15,
"MaintainerId": 18
},
{
"FilterListId": 16,
"MaintainerId": 18
},
{
"FilterListId": 17,
"MaintainerId": 19
},
{
"FilterListId": 18,
"MaintainerId": 20
},
{
"FilterListId": 307,
"MaintainerId": 20
},
{
"FilterListId": 19,
"MaintainerId": 21
},
{
"FilterListId": 308,
"MaintainerId": 21
},
{
"FilterListId": 20,
"MaintainerId": 22
},
{
"FilterListId": 23,
"MaintainerId": 23
},
{
"FilterListId": 24,
"MaintainerId": 23
},
{
"FilterListId": 25,
"MaintainerId": 23
},
{
"FilterListId": 26,
"MaintainerId": 23
},
{
"FilterListId": 37,
"MaintainerId": 23
},
{
"FilterListId": 75,
"MaintainerId": 23
},
{
"FilterListId": 76,
"MaintainerId": 23
},
{
"FilterListId": 77,
"MaintainerId": 23
},
{
"FilterListId": 121,
"MaintainerId": 23
},
{
"FilterListId": 122,
"MaintainerId": 23
},
{
"FilterListId": 123,
"MaintainerId": 23
},
{
"FilterListId": 124,
"MaintainerId": 23
},
{
"FilterListId": 125,
"MaintainerId": 23
},
{
"FilterListId": 126,
"MaintainerId": 23
},
{
"FilterListId": 127,
"MaintainerId": 23
},
{
"FilterListId": 128,
"MaintainerId": 23
},
{
"FilterListId": 129,
"MaintainerId": 23
},
{
"FilterListId": 130,
"MaintainerId": 23
},
{
"FilterListId": 27,
"MaintainerId": 24
}
]

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,163 @@
[
{
"Id": 2,
"HomeUrl": null,
"Name": "AppliliZ",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 3,
"HomeUrl": "https://bradconte.com/",
"Name": "Brad Conte",
"TwitterHandle": "bradconte",
"EmailAddress": null
},
{
"Id": 4,
"HomeUrl": "https://forum.xda-developers.com/member.php?u=4877037",
"Name": "BSDgeek_Jake",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 5,
"HomeUrl": "https://www.michaeltrimm.com/",
"Name": "Michael Trimm",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 6,
"HomeUrl": "https://eyeo.com/",
"Name": "eyeo GmbH",
"TwitterHandle": "eyeo",
"EmailAddress": "info@eyeo.com"
},
{
"Id": 7,
"HomeUrl": "https://easylist.to/",
"Name": "The EasyList Authors",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 8,
"HomeUrl": "https://github.com/mayve",
"Name": "mayve",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 9,
"HomeUrl": "http://joxeankoret.com/",
"Name": "Joxean Koret",
"TwitterHandle": null,
"EmailAddress": "admin@oxeankoret.com"
},
{
"Id": 10,
"HomeUrl": "https://www.malwaredomainlist.com/",
"Name": "Malware Domain List Community",
"TwitterHandle": "_MDL_",
"EmailAddress": null
},
{
"Id": 11,
"HomeUrl": "https://forums.lanik.us/memberlist.php?mode=viewprofile&u=542",
"Name": "Lian",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 12,
"HomeUrl": "https://forums.lanik.us/memberlist.php?mode=viewprofile&u=2266",
"Name": "Crits",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 13,
"HomeUrl": "https://forums.lanik.us/memberlist.php?mode=viewprofile&u=1260",
"Name": "smed79",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 14,
"HomeUrl": "https://www.fanboy.co.nz/",
"Name": "fanboy",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 15,
"HomeUrl": "https://forums.lanik.us/memberlist.php?mode=viewprofile&u=333",
"Name": "MonztA",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 16,
"HomeUrl": "https://forums.lanik.us/memberlist.php?mode=viewprofile&u=1488",
"Name": "Famlam",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 17,
"HomeUrl": "https://forums.lanik.us/memberlist.php?mode=viewprofile&u=1400",
"Name": "Khrin",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 18,
"HomeUrl": "https://github.com/SlowMemory",
"Name": "SlowMemory",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 19,
"HomeUrl": "https://www.blogger.com/profile/09662737599549871224",
"Name": "MVPS HOSTS Maintainer",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 20,
"HomeUrl": "https://github.com/taylr",
"Name": "Matt Taylor",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 21,
"HomeUrl": "https://github.com/hoshsadiq/adblock-nocoin-list",
"Name": "Hosh",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 22,
"HomeUrl": "https://github.com/DandelionSprout",
"Name": "Imre Kristoffer Eilertsen",
"TwitterHandle": null,
"EmailAddress": null
},
{
"Id": 23,
"HomeUrl": "https://abuse.ch/",
"Name": "abuse.ch",
"TwitterHandle": "abuse_ch",
"EmailAddress": "contactme@abuse.ch"
},
{
"Id": 24,
"HomeUrl": "https://github.com/metaphoricgiraffe",
"Name": "metaphoricgiraffe",
"TwitterHandle": null,
"EmailAddress": null
}
]

View file

@ -0,0 +1,94 @@
[
{
"MergeFilterListId": 11,
"UpstreamFilterListId": 12
},
{
"MergeFilterListId": 13,
"UpstreamFilterListId": 12
},
{
"MergeFilterListId": 13,
"UpstreamFilterListId": 14
},
{
"MergeFilterListId": 21,
"UpstreamFilterListId": 23
},
{
"MergeFilterListId": 22,
"UpstreamFilterListId": 24
},
{
"MergeFilterListId": 120,
"UpstreamFilterListId": 25
},
{
"MergeFilterListId": 22,
"UpstreamFilterListId": 26
},
{
"MergeFilterListId": 22,
"UpstreamFilterListId": 37
},
{
"MergeFilterListId": 21,
"UpstreamFilterListId": 75
},
{
"MergeFilterListId": 120,
"UpstreamFilterListId": 76
},
{
"MergeFilterListId": 22,
"UpstreamFilterListId": 77
},
{
"MergeFilterListId": 21,
"UpstreamFilterListId": 121
},
{
"MergeFilterListId": 22,
"UpstreamFilterListId": 122
},
{
"MergeFilterListId": 21,
"UpstreamFilterListId": 123
},
{
"MergeFilterListId": 22,
"UpstreamFilterListId": 124
},
{
"MergeFilterListId": 21,
"UpstreamFilterListId": 125
},
{
"MergeFilterListId": 22,
"UpstreamFilterListId": 126
},
{
"MergeFilterListId": 120,
"UpstreamFilterListId": 127
},
{
"MergeFilterListId": 120,
"UpstreamFilterListId": 128
},
{
"MergeFilterListId": 22,
"UpstreamFilterListId": 129
},
{
"MergeFilterListId": 21,
"UpstreamFilterListId": 130
},
{
"MergeFilterListId": 11,
"UpstreamFilterListId": 301
},
{
"MergeFilterListId": 13,
"UpstreamFilterListId": 301
}
]

View file

@ -0,0 +1,20 @@
[
{
"Id": 1,
"DownloadUrl": "https://github.com/gorhill/uBlock#installation",
"HomeUrl": "https://github.com/gorhill/uBlock",
"Name": "uBlock Origin"
},
{
"Id": 2,
"DownloadUrl": "https://adblockplus.org/",
"HomeUrl": "https://adblockplus.org/",
"Name": "Adblock Plus"
},
{
"Id": 3,
"DownloadUrl": "https://adguard.com/en/download.html",
"HomeUrl": "https://adguard.com/",
"Name": "AdGuard"
}
]

View file

@ -0,0 +1,14 @@
[
{
"SoftwareId": 2,
"SyntaxId": 3
},
{
"SoftwareId": 1,
"SyntaxId": 4
},
{
"SoftwareId": 3,
"SyntaxId": 6
}
]

View file

@ -11,15 +11,14 @@ public FilterListsDbContext(DbContextOptions options)
{
}
public DbSet<FilterList> FilterLists { get; set; }
public DbSet<Language> Languages { get; set; }
public DbSet<License> Licenses { get; set; }
public DbSet<Maintainer> Maintainers { get; set; }
public DbSet<Rule> Rules { get; set; }
public DbSet<Software> Software { get; set; }
public DbSet<Syntax> Syntaxes { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
ApplyConfigurationsEntities(modelBuilder);
ApplyConfigurationsJunctions(modelBuilder);
base.OnModelCreating(modelBuilder);
}
private static void ApplyConfigurationsEntities(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new FilterListTypeConfiguration());
modelBuilder.ApplyConfiguration(new LanguageTypeConfiguration());
@ -28,15 +27,39 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.ApplyConfiguration(new RuleTypeConfiguration());
modelBuilder.ApplyConfiguration(new SoftwareTypeConfiguration());
modelBuilder.ApplyConfiguration(new SyntaxTypeConfiguration());
}
private static void ApplyConfigurationsJunctions(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new FilterListLanguageTypeConfiguration());
modelBuilder.ApplyConfiguration(new FilterListMaintainerTypeConfiguration());
modelBuilder.ApplyConfiguration(new FilterListRuleTypeConfiguration());
modelBuilder.ApplyConfiguration(new ForkTypeConfiguration());
modelBuilder.ApplyConfiguration(new MergeTypeConfiguration());
modelBuilder.ApplyConfiguration(new SoftwareSyntaxTypeConfiguration());
base.OnModelCreating(modelBuilder);
}
#region Entities
public DbSet<FilterList> FilterLists { get; set; }
public DbSet<Language> Languages { get; set; }
public DbSet<License> Licenses { get; set; }
public DbSet<Maintainer> Maintainers { get; set; }
public DbSet<Rule> Rules { get; set; }
public DbSet<Software> Software { get; set; }
public DbSet<Syntax> Syntaxes { get; set; }
#endregion
#region Junctions
public DbSet<FilterListLanguage> FilterListLanguages { get; set; }
public DbSet<FilterListMaintainer> FilterListMaintainers { get; set; }
public DbSet<FilterListRule> FilterListRules { get; set; }
public DbSet<Fork> Forks { get; set; }
public DbSet<Merge> Merges { get; set; }
public DbSet<SoftwareSyntax> SoftwareSyntaxes { get; set; }
#endregion
}
}