diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 534d983f..94a69eb4 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -11,7 +11,7 @@ Baseline from before doing anything seeding a medium level with full text 2020-01-21 16:49:39.4481|INFO|Seeder|500 Widgets seeded in 21968 ms After round one of improvements (less text in seed data notes, not calling savechanges or add async) -//about 2 seconds came from the async db stuff and the rest was from using less text so less indexing which isn't really a permanent solution just a minor one +//about 2 seconds came from the async db stuff and the rest was from using less text so less indexing which isn't really a permanent solution just a workaround 2020-01-23 16:57:57.0422|INFO|Seeder|75 Users seeded in 2398 ms 2020-01-23 16:58:11.9983|INFO|Seeder|500 Widgets seeded in 14958 ms @@ -20,7 +20,7 @@ TODO: Search indexing is painfully slow, it accounts for 16 of 22 seconds when c - Re-code it not using EF but directly interacting with the DB - Maybe it's a case for stored procedures or something? - + TODO: DataFilter how to distinguish between filtering on specific ID value or on value column diff --git a/server/AyaNova/Controllers/WidgetController.cs b/server/AyaNova/Controllers/WidgetController.cs index abf01b60..b845a38e 100644 --- a/server/AyaNova/Controllers/WidgetController.cs +++ b/server/AyaNova/Controllers/WidgetController.cs @@ -176,7 +176,7 @@ namespace AyaNova.Api.Controllers /// Automatically filled from route path, no need to specify in body /// [HttpPost] - public async Task PostWidget([FromBody] Widget inObj, ApiVersion apiVersion) + public IActionResult PostWidget([FromBody] Widget inObj, ApiVersion apiVersion) { if (!serverState.IsOpen) return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); @@ -192,7 +192,7 @@ namespace AyaNova.Api.Controllers return BadRequest(new ApiErrorResponse(ModelState)); //Create and validate - Widget o = await biz.CreateAsync(inObj); + Widget o = biz.Create(inObj); if (o == null) return BadRequest(new ApiErrorResponse(biz.Errors)); else diff --git a/server/AyaNova/biz/Search.cs b/server/AyaNova/biz/Search.cs index 55bd323c..5ed90357 100644 --- a/server/AyaNova/biz/Search.cs +++ b/server/AyaNova/biz/Search.cs @@ -458,7 +458,7 @@ namespace AyaNova.Biz /// /// Process the keywords into the dictionary - /// NOTE: NAME parameter is in ADDITION to the NAME also being on of the strings passed in text parameter + /// NOTE: NAME parameter is in ADDITION to the NAME also being one of the strings passed in text parameter /// private static void ProcessKeywords(SearchIndexProcessObjectParameters p, bool newRecord)//long localeId, long objectID, AyaType objectType, string name, params string[] text) { diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs index f70b55fa..c244e6ca 100644 --- a/server/AyaNova/biz/WidgetBiz.cs +++ b/server/AyaNova/biz/WidgetBiz.cs @@ -67,7 +67,7 @@ namespace AyaNova.Biz //route linked version for external api access - internal async Task CreateAsync(Widget inObj) + internal Widget Create(Widget inObj) { Validate(inObj, null); if (HasErrors) @@ -83,22 +83,14 @@ namespace AyaNova.Biz outObj.Tags = TagUtil.NormalizeTags(outObj.Tags); outObj.CustomFields = JsonUtil.CompactJson(outObj.CustomFields); - //Save to db - var TheContext = ct; - if (TheContext == null) - TheContext = ServiceProviderProvider.DBContext; - //TEST SPEED IMPROVEMENTS - - //ORIGINALLY - // await TheContext.Widget.AddAsync(outObj); - // await TheContext.SaveChangesAsync(); - + //Save to db + //add syncronously and don't save but let the log save //THIS SAVED 1 SECOND OUT OF 22 for seeding 500 widgets - TheContext.Widget.Add(outObj); + ct.Widget.Add(outObj); //Handle child and associated items: - EventLogProcessor.LogEventToDatabaseAndSaveEntireContext(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), TheContext); + EventLogProcessor.LogEventToDatabaseAndSaveEntireContext(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct); //This takes 16 seconds out of 22 when seeding 500 widgets @@ -106,7 +98,7 @@ namespace AyaNova.Biz //This takes 2 seconds out of 22 when seeding 500 widgets - TagUtil.ProcessUpdateTagsInRepository(TheContext, outObj.Tags, null); + TagUtil.ProcessUpdateTagsInRepository(ct, outObj.Tags, null); return outObj; } diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index c6af1379..42f3d1c4 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -622,7 +622,7 @@ namespace AyaNova.Util //var NewObject = Cached_WidgetBiz.CreateAsync(o).Result; //test without cached widgetbiz WidgetBiz biz = WidgetBiz.GetBizInternal(ServiceProviderProvider.DBContext); - var NewObject = biz.CreateAsync(o).Result; + var NewObject = biz.Create(o); if (NewObject == null) { log.LogError($"Seeder::GenSeedWidget error creating widget {o.Name}\r\n" + biz.GetErrorsAsString());