From 4f0a2d08da79cd7b234d9a3fcdee47f7eda4a49c Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 28 Jan 2020 00:28:52 +0000 Subject: [PATCH] --- devdocs/todo.txt | 8 ++------ .../AyaNova/ControllerHelpers/ApiCustomExceptionFilter.cs | 2 +- server/AyaNova/Controllers/ApiRootController.cs | 2 +- server/AyaNova/Startup.cs | 3 ++- server/AyaNova/util/Seeder.cs | 4 +--- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/devdocs/todo.txt b/devdocs/todo.txt index f8f803d9..11a8398e 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -4,13 +4,9 @@ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNTcxODU5OTU0IiwiZXhwIjoiMTU3MjQ ## IMMEDIATE ITEMS -TODO: Ensure scaleability by checking for performance issues now before replicating code (particularly in widget etc) - - As per this document https://docs.microsoft.com/en-us/aspnet/core/performance/performance-best-practices?view=aspnetcore-3.1 - - For scaleability go back to async only for any db calls functions like creating widgets etc + -TODO: look for any line of code that does this or similar: await Task.CompletedTask, [anything].Result; - - Needs to be turned into a true async function or not an async function - + TODO: Look at any of my middleware code as it's a HOT PATH, make sure it's async db access etc and nothing slowing it down diff --git a/server/AyaNova/ControllerHelpers/ApiCustomExceptionFilter.cs b/server/AyaNova/ControllerHelpers/ApiCustomExceptionFilter.cs index d2e89524..129a3798 100644 --- a/server/AyaNova/ControllerHelpers/ApiCustomExceptionFilter.cs +++ b/server/AyaNova/ControllerHelpers/ApiCustomExceptionFilter.cs @@ -93,7 +93,7 @@ namespace AyaNova.Api.ControllerHelpers //This line is critical, without it the response is not proper and fails in various clients (postman, xunit tests with httpclient) context.ExceptionHandled = true; - //context.Result + response.WriteAsync(JsonConvert.SerializeObject( new ApiErrorResponse(ApiErrorCode.API_SERVER_ERROR, "Server internal error", "See server log for details"), diff --git a/server/AyaNova/Controllers/ApiRootController.cs b/server/AyaNova/Controllers/ApiRootController.cs index 61bb3579..3b15bc24 100644 --- a/server/AyaNova/Controllers/ApiRootController.cs +++ b/server/AyaNova/Controllers/ApiRootController.cs @@ -63,7 +63,7 @@ namespace AyaNova.Api.Controllers AyaNova manual

API explorer

Email AyaNova support

-

{LocaleBiz.GetDefaultLocalizedTextAsync("HelpLicense").Result}

+

{await LocaleBiz.GetDefaultLocalizedTextAsync("HelpLicense")}

{AyaNova.Core.License.LicenseInfo}

Schema version

{AySchema.currentSchema.ToString()}
diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index 55156f3a..9526af5a 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -364,7 +364,8 @@ namespace AyaNova var ct = context.RequestServices.GetService(); //get the user record - var u = ct.User.AsNoTracking().Where(a => a.Id == userId).Select(m => new { roles = m.Roles, name = m.Name, id = m.Id, localeId = m.LocaleId }).First(); + //var u = ct.User.AsNoTracking().Where(a => a.Id == userId).Select(m => new { roles = m.Roles, name = m.Name, id = m.Id, localeId = m.LocaleId }).First(); + var u = await ct.User.AsNoTracking().Where(a => a.Id == userId).Select(m => new { roles = m.Roles, name = m.Name, id = m.Id, localeId = m.LocaleId }).FirstAsync(); context.Request.HttpContext.Items["AY_ROLES"] = u.roles; context.Request.HttpContext.Items["AY_USERNAME"] = u.name; context.Request.HttpContext.Items["AY_USER_ID"] = u.id; diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index 4c91fa78..61cedc58 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -605,9 +605,7 @@ namespace AyaNova.Util o.CustomFields = $@"{{c1:""{c1}"",c2:""{c2}"",c3:{c3},c4:{c4},c5:{c5}}}"; - - //var NewObject = Cached_WidgetBiz.CreateAsync(o).Result; - //test without cached widgetbiz + WidgetBiz biz = WidgetBiz.GetBizInternal(ServiceProviderProvider.DBContext); var NewObject = await biz.CreateAsync(o); if (NewObject == null)