This commit is contained in:
@@ -449,7 +449,7 @@ namespace AyaNova
|
||||
{
|
||||
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
|
||||
Util.Seeder.SeedDatabase(Util.Seeder.SeedLevel.SmallOneManShopTrialDataSet, -7);//#############################################################################################
|
||||
Util.Seeder.SeedDatabase(Util.Seeder.SeedLevel.MediumLocalServiceCompanyTrialDataSet, -7).Wait();//#############################################################################################
|
||||
}
|
||||
//TESTING
|
||||
#endif
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace AyaNova.Models
|
||||
//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
|
||||
public User User { get; set; }
|
||||
[Required]
|
||||
public long UserId { get; set; }
|
||||
|
||||
public long? UserId { get; set; }
|
||||
|
||||
public Widget()
|
||||
{
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace AyaNova.Util
|
||||
//id, text, longtext, boolean, currency,
|
||||
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,"+
|
||||
"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
|
||||
//exec("CREATE UNIQUE INDEX awidget_serial_idx ON awidget (serial);");
|
||||
|
||||
@@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Bogus;
|
||||
using AyaNova.Api.ControllerHelpers;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace AyaNova.Util
|
||||
@@ -52,13 +53,13 @@ namespace AyaNova.Util
|
||||
//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;
|
||||
SeededUserCount = 0;
|
||||
@@ -190,7 +191,7 @@ namespace AyaNova.Util
|
||||
//100 widgets
|
||||
watch = new Stopwatch();
|
||||
watch.Start();
|
||||
GenSeedWidgetAsync(log, 100);
|
||||
await GenSeedWidgetAsync(log, 100);
|
||||
//PERF
|
||||
watch.Stop();
|
||||
LogStatus(JobId, LogJob, log, $"100 Widgets seeded in {watch.ElapsedMilliseconds} ms");
|
||||
@@ -251,7 +252,7 @@ namespace AyaNova.Util
|
||||
watch = new Stopwatch();
|
||||
watch.Start();
|
||||
|
||||
GenSeedWidgetAsync(log, 500);
|
||||
await GenSeedWidgetAsync(log, 500);
|
||||
//PERF
|
||||
watch.Stop();
|
||||
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....");
|
||||
watch = new Stopwatch();
|
||||
watch.Start();
|
||||
GenSeedWidgetAsync(log, 5000);
|
||||
await GenSeedWidgetAsync(log, 5000);
|
||||
|
||||
//PERF
|
||||
watch.Stop();
|
||||
@@ -402,7 +403,7 @@ namespace AyaNova.Util
|
||||
LogStatus(JobId, LogJob, log, $"Seeding 20,000 Widgets....");
|
||||
watch = new Stopwatch();
|
||||
watch.Start();
|
||||
GenSeedWidgetAsync(log, 20000);
|
||||
await GenSeedWidgetAsync(log, 20000);
|
||||
watch.Stop();
|
||||
LogStatus(JobId, LogJob, log, $"20k Widgets seeded in {watch.ElapsedMilliseconds} ms");
|
||||
#endregion genhuge
|
||||
@@ -586,7 +587,7 @@ namespace AyaNova.Util
|
||||
//////////////////////////////////////////////////////
|
||||
//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();
|
||||
@@ -596,8 +597,6 @@ namespace AyaNova.Util
|
||||
Random random = new Random();
|
||||
|
||||
|
||||
|
||||
|
||||
for (int x = 0; x < count; x++)
|
||||
{
|
||||
Widget o = new Widget();
|
||||
@@ -630,6 +629,7 @@ namespace AyaNova.Util
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user