This commit is contained in:
@@ -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
|
- 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
|
- 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??
|
- 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)
|
- Update all the other routes to include search indexing (attachments, tags etc, anything with text in it)
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,7 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
//todo:
|
//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
|
//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)
|
internal static UserBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext)
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace AyaNova.Util
|
|||||||
GenSeedUser(log, 1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.AccountingFull, UserType.NonSchedulable);
|
GenSeedUser(log, 1, AuthorizationRoles.DispatchFull | AuthorizationRoles.InventoryFull | AuthorizationRoles.AccountingFull, UserType.NonSchedulable);
|
||||||
|
|
||||||
//200 widgets
|
//200 widgets
|
||||||
GenSeedWidget(200);
|
GenSeedWidget(log, 200);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
//This is for a typical AyaNova medium busy shop
|
//This is for a typical AyaNova medium busy shop
|
||||||
@@ -103,7 +103,7 @@ namespace AyaNova.Util
|
|||||||
GenSeedUser(log, 10, AuthorizationRoles.ClientLimited, UserType.Client);
|
GenSeedUser(log, 10, AuthorizationRoles.ClientLimited, UserType.Client);
|
||||||
|
|
||||||
//2000 widgets
|
//2000 widgets
|
||||||
GenSeedWidget(2000);
|
GenSeedWidget(log, 2000);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
//this is a large corporation with multiple branches in multiple locations all in the same country
|
//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);
|
GenSeedUser(log, 100, AuthorizationRoles.ClientLimited, UserType.Client);
|
||||||
|
|
||||||
//20000 widgets
|
//20000 widgets
|
||||||
GenSeedWidget(20000);
|
GenSeedWidget(log, 20000);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -274,8 +274,8 @@ namespace AyaNova.Util
|
|||||||
u.UserOptions = new UserOptions(1);
|
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");
|
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);
|
var NewObject = await Biz.CreateAsync(u);
|
||||||
if (TheUser == null)
|
if (NewObject == null)
|
||||||
{
|
{
|
||||||
log.LogError($"Seeder::GenSeedUser error creating user {u.Name}\r\n" + Biz.GetErrorsAsString());
|
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());
|
throw new System.Exception("Seeder::GenSeedUser error creating user\r\n" + Biz.GetErrorsAsString());
|
||||||
@@ -287,44 +287,31 @@ namespace AyaNova.Util
|
|||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
//Seed widget for testing
|
//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
|
//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();
|
var f = new Bogus.Faker();
|
||||||
for (int x = 0; x < count; x++)
|
for (int x = 0; x < count; x++)
|
||||||
{
|
{
|
||||||
Widget o = new Widget();
|
Widget o = new Widget();
|
||||||
o.Name = f.Commerce.ProductName();
|
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.StartDate = f.Date.Between(DateTime.Now, DateTime.Now.AddMinutes(60));
|
||||||
o.EndDate = f.Date.Between(DateTime.Now.AddMinutes(90), DateTime.Now.AddHours(5));
|
o.EndDate = f.Date.Between(DateTime.Now.AddMinutes(90), DateTime.Now.AddHours(5));
|
||||||
o.DollarAmount = Convert.ToDecimal(f.Commerce.Price());
|
o.DollarAmount = Convert.ToDecimal(f.Commerce.Price());
|
||||||
o.OwnerId = 1;
|
o.OwnerId = 1;
|
||||||
//this is nonsense but just to test an enum
|
//this is nonsense but just to test an enum
|
||||||
o.Roles = AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited;
|
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<long> WidgetsAdded = new List<long>();
|
|
||||||
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
|
}//eoc
|
||||||
|
|||||||
Reference in New Issue
Block a user