This commit is contained in:
2020-01-23 23:59:32 +00:00
parent b14afa1726
commit 8edeae4c04
4 changed files with 15 additions and 15 deletions

View File

@@ -449,7 +449,7 @@ namespace AyaNova
{ {
AyaNova.Core.License.Fetch(apiServerState, dbContext, _newLog); AyaNova.Core.License.Fetch(apiServerState, dbContext, _newLog);
//NOTE: For unit testing make sure the time zone in util is set to the same figure as here to ensure list filter by date tests will work because server is on same page as user in terms of time //NOTE: For unit testing make sure the time zone in util is set to the same figure as here to ensure list filter by date tests will work because server is on same page as user in terms of time
Util.Seeder.SeedDatabase(Util.Seeder.SeedLevel.SmallOneManShopTrialDataSet, -7);//############################################################################################# Util.Seeder.SeedDatabase(Util.Seeder.SeedLevel.MediumLocalServiceCompanyTrialDataSet, -7).Wait();//#############################################################################################
} }
//TESTING //TESTING
#endif #endif

View File

@@ -30,8 +30,8 @@ namespace AyaNova.Models
//https://docs.microsoft.com/en-us/ef/core/modeling/relationships#other-relationship-patterns //https://docs.microsoft.com/en-us/ef/core/modeling/relationships#other-relationship-patterns
[JsonIgnore]//hide from being returned (as null anyway) with User object in routes [JsonIgnore]//hide from being returned (as null anyway) with User object in routes
public User User { get; set; } public User User { get; set; }
[Required]
public long UserId { get; set; } public long? UserId { get; set; }
public Widget() public Widget()
{ {

View File

@@ -210,7 +210,7 @@ namespace AyaNova.Util
//id, text, longtext, boolean, currency, //id, text, longtext, boolean, currency,
exec("CREATE TABLE awidget (id BIGSERIAL PRIMARY KEY, name varchar(255) not null, serial bigint not null," + exec("CREATE TABLE awidget (id BIGSERIAL PRIMARY KEY, name varchar(255) not null, serial bigint not null," +
"startdate timestamp, enddate timestamp, dollaramount decimal(19,5), active bool, roles int4, count integer,"+ "startdate timestamp, enddate timestamp, dollaramount decimal(19,5), active bool, roles int4, count integer,"+
"notes text, userid bigint, customfields text, tags varchar(255) ARRAY)"); "notes text, userid bigint null, customfields text, tags varchar(255) ARRAY)");
//TEST TEST TEST ONLY FOR DEVELOPMENT TESTING TO ENSURE UNIQUENESS //TEST TEST TEST ONLY FOR DEVELOPMENT TESTING TO ENSURE UNIQUENESS
//exec("CREATE UNIQUE INDEX awidget_serial_idx ON awidget (serial);"); //exec("CREATE UNIQUE INDEX awidget_serial_idx ON awidget (serial);");

View File

@@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
using Bogus; using Bogus;
using AyaNova.Api.ControllerHelpers; using AyaNova.Api.ControllerHelpers;
using System.Diagnostics; using System.Diagnostics;
using System.Threading.Tasks;
namespace AyaNova.Util namespace AyaNova.Util
@@ -52,13 +53,13 @@ namespace AyaNova.Util
//Seed database for trial and testing purposes //Seed database for trial and testing purposes
// //
public static void SeedDatabase(SeedLevel slevel, Decimal timeZoneOffset) public async static Task SeedDatabase(SeedLevel slevel, Decimal timeZoneOffset)
{ {
SeedDatabase(slevel, Guid.Empty, timeZoneOffset); await SeedDatabase(slevel, Guid.Empty, timeZoneOffset);
} }
public static void SeedDatabase(SeedLevel slevel, Guid JobId, Decimal timeZoneOffset) public async static Task SeedDatabase(SeedLevel slevel, Guid JobId, Decimal timeZoneOffset)
{ {
bool LogJob = JobId != Guid.Empty; bool LogJob = JobId != Guid.Empty;
SeededUserCount = 0; SeededUserCount = 0;
@@ -190,7 +191,7 @@ namespace AyaNova.Util
//100 widgets //100 widgets
watch = new Stopwatch(); watch = new Stopwatch();
watch.Start(); watch.Start();
GenSeedWidgetAsync(log, 100); await GenSeedWidgetAsync(log, 100);
//PERF //PERF
watch.Stop(); watch.Stop();
LogStatus(JobId, LogJob, log, $"100 Widgets seeded in {watch.ElapsedMilliseconds} ms"); LogStatus(JobId, LogJob, log, $"100 Widgets seeded in {watch.ElapsedMilliseconds} ms");
@@ -251,7 +252,7 @@ namespace AyaNova.Util
watch = new Stopwatch(); watch = new Stopwatch();
watch.Start(); watch.Start();
GenSeedWidgetAsync(log, 500); await GenSeedWidgetAsync(log, 500);
//PERF //PERF
watch.Stop(); watch.Stop();
LogStatus(JobId, LogJob, log, $"500 Widgets seeded in {watch.ElapsedMilliseconds} ms"); LogStatus(JobId, LogJob, log, $"500 Widgets seeded in {watch.ElapsedMilliseconds} ms");
@@ -326,7 +327,7 @@ namespace AyaNova.Util
LogStatus(JobId, LogJob, log, $"Seeding 5,000 Widgets...."); LogStatus(JobId, LogJob, log, $"Seeding 5,000 Widgets....");
watch = new Stopwatch(); watch = new Stopwatch();
watch.Start(); watch.Start();
GenSeedWidgetAsync(log, 5000); await GenSeedWidgetAsync(log, 5000);
//PERF //PERF
watch.Stop(); watch.Stop();
@@ -402,7 +403,7 @@ namespace AyaNova.Util
LogStatus(JobId, LogJob, log, $"Seeding 20,000 Widgets...."); LogStatus(JobId, LogJob, log, $"Seeding 20,000 Widgets....");
watch = new Stopwatch(); watch = new Stopwatch();
watch.Start(); watch.Start();
GenSeedWidgetAsync(log, 20000); await GenSeedWidgetAsync(log, 20000);
watch.Stop(); watch.Stop();
LogStatus(JobId, LogJob, log, $"20k Widgets seeded in {watch.ElapsedMilliseconds} ms"); LogStatus(JobId, LogJob, log, $"20k Widgets seeded in {watch.ElapsedMilliseconds} ms");
#endregion genhuge #endregion genhuge
@@ -586,7 +587,7 @@ namespace AyaNova.Util
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
//Seed widget for testing //Seed widget for testing
// //
public static async void GenSeedWidgetAsync(ILogger log, int count) public static async Task GenSeedWidgetAsync(ILogger log, int count)
{ {
var f = new Bogus.Faker(); var f = new Bogus.Faker();
@@ -596,8 +597,6 @@ namespace AyaNova.Util
Random random = new Random(); Random random = new Random();
for (int x = 0; x < count; x++) for (int x = 0; x < count; x++)
{ {
Widget o = new Widget(); Widget o = new Widget();
@@ -626,10 +625,11 @@ namespace AyaNova.Util
var NewObject = await Cached_WidgetBiz.CreateAsync(o); var NewObject = await Cached_WidgetBiz.CreateAsync(o);
if (NewObject == null) if (NewObject == null)
{ {
log.LogError($"Seeder::GenSeedWidget error creating widget {o.Name}\r\n" + Cached_WidgetBiz.GetErrorsAsString()); log.LogError($"Seeder::GenSeedWidget error creating widget {o.Name}\r\n" + Cached_WidgetBiz.GetErrorsAsString());
throw new System.Exception("Seeder::GenSeedWidget error creating widget\r\n" + Cached_WidgetBiz.GetErrorsAsString()); throw new System.Exception("Seeder::GenSeedWidget error creating widget\r\n" + Cached_WidgetBiz.GetErrorsAsString());
} }
} }
} }