diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 7f065343..04ac545d 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -29,10 +29,11 @@ IMMEDIATE ITEMS: ================ - - Search and search text indexing - + - Search and search text indexing - Update all the seeder code to add search indexing so can properly test huge search datasets + - Current item is widgets - Need to find a way to add random text to Notes fields that varies but has some overlap ideally + - bugbug: why is the single letter a being indexed? Missing shortness filter, A not in stopwords for english?? - Update all the other routes to include search indexing (attachments, tags etc, anything with text in it) diff --git a/server/AyaNova/biz/UserBiz.cs b/server/AyaNova/biz/UserBiz.cs index 17dc86ca..d78c5699 100644 --- a/server/AyaNova/biz/UserBiz.cs +++ b/server/AyaNova/biz/UserBiz.cs @@ -35,9 +35,7 @@ namespace AyaNova.Biz } //todo: - //Then after that go into seeder and re-org to use the biz object to create the users (it will be slower but WTF other way is this going to work properly to generate data??) - - //then after that go into widget and anywhere else that there is this associated type code being called for event and search and implement everywhere, + //then after that go into widget and anywhere else that there is this associated type code being called for event and search and implement everywhere, //then update seeder code to use it and get back on to the main critical path again in the todo internal static UserBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext) diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 0b2dcc48..b4771086 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -62,7 +62,7 @@ namespace AyaNova.Util GenSeedUser(log, 1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.AccountingFull, UserType.NonSchedulable); //200 widgets - GenSeedWidget(200); + GenSeedWidget(log, 200); break; //This is for a typical AyaNova medium busy shop @@ -103,7 +103,7 @@ namespace AyaNova.Util GenSeedUser(log, 10, AuthorizationRoles.ClientLimited, UserType.Client); //2000 widgets - GenSeedWidget(2000); + GenSeedWidget(log, 2000); break; //this is a large corporation with multiple branches in multiple locations all in the same country @@ -152,7 +152,7 @@ namespace AyaNova.Util GenSeedUser(log, 100, AuthorizationRoles.ClientLimited, UserType.Client); //20000 widgets - GenSeedWidget(20000); + GenSeedWidget(log, 20000); break; } @@ -274,8 +274,8 @@ namespace AyaNova.Util u.UserOptions = new UserOptions(1); u.UserOptions.EmailAddress = p.Email.Replace("gmail.com", "helloayanova.com").Replace("hotmail.com", "helloayanova.com").Replace("yahoo.com", "helloayanova.com"); - var TheUser = await Biz.CreateAsync(u); - if (TheUser == null) + var NewObject = await Biz.CreateAsync(u); + if (NewObject == null) { log.LogError($"Seeder::GenSeedUser error creating user {u.Name}\r\n" + Biz.GetErrorsAsString()); throw new System.Exception("Seeder::GenSeedUser error creating user\r\n" + Biz.GetErrorsAsString()); @@ -287,44 +287,31 @@ namespace AyaNova.Util ////////////////////////////////////////////////////// //Seed widget for testing // - public static void GenSeedWidget(int count) + public static async void GenSeedWidget(ILogger log, int count) { //get a context just for this op to save memory on changetracking - AyContext ct = ServiceProviderProvider.DBContext; + //AyContext ct = ServiceProviderProvider.DBContext; + WidgetBiz Biz = WidgetBiz.GetBizInternal(ServiceProviderProvider.DBContext); var f = new Bogus.Faker(); for (int x = 0; x < count; x++) { Widget o = new Widget(); o.Name = f.Commerce.ProductName(); - o.Active = f.Random.Bool(); + o.Active = true; o.StartDate = f.Date.Between(DateTime.Now, DateTime.Now.AddMinutes(60)); o.EndDate = f.Date.Between(DateTime.Now.AddMinutes(90), DateTime.Now.AddHours(5)); o.DollarAmount = Convert.ToDecimal(f.Commerce.Price()); o.OwnerId = 1; //this is nonsense but just to test an enum o.Roles = AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited; - ct.Widget.Add(o); + o.Notes = f.Lorem.Paragraph(); + var NewObject = await Biz.CreateAsync(o); + if (NewObject == null) + { + log.LogError($"Seeder::GenSeedWidget error creating widget {o.Name}\r\n" + Biz.GetErrorsAsString()); + throw new System.Exception("Seeder::GenSeedWidget error creating widget\r\n" + Biz.GetErrorsAsString()); + } } - //Save the changes to get the ID values - ct.SaveChanges(); - - //Now that we have the ID values bulk add the event log entries - //To save a db call iterate the local collection in the context, but... - //can't modify the context in the foreach, even if it's another collection entirely, so need to save the id's in a temporary list - List WidgetsAdded = new List(); - foreach (Widget w in ct.Widget.Local) - { - WidgetsAdded.Add(w.Id); - } - - //Now we have all the id's can actually add them to the context - foreach (long l in WidgetsAdded) - { - EventLogProcessor.AddEntry(new Event(1, l, AyaType.Widget, AyaEvent.Created), ct); - } - - //Now save the Event Log entries - ct.SaveChanges(); } }//eoc