diff --git a/server/AyaNova/Controllers/LocaleController.cs b/server/AyaNova/Controllers/LocaleController.cs index 13fdd06a..abf1af45 100644 --- a/server/AyaNova/Controllers/LocaleController.cs +++ b/server/AyaNova/Controllers/LocaleController.cs @@ -110,13 +110,13 @@ namespace AyaNova.Api.Controllers #if (DEBUG) /// - /// Get all unique Locale keys that were tracked + /// Get a coverage report of locale keys used versus unused /// Required roles: Any /// /// - /// List in alphabetical order of all unique locale keys requested since last server reboot - [HttpGet("RequestedKeyList")] - public ActionResult RequestedKeyList() + /// Report of all unique locale keys requested since last server reboot + [HttpGet("LocaleKeyCoverage")] + public ActionResult LocaleKeyCoverage() { if (serverState.IsClosed) { @@ -126,7 +126,7 @@ namespace AyaNova.Api.Controllers //Instantiate the business object handler LocaleBiz biz = new LocaleBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items)); - var l = biz.RequestedKeyList(); + var l = biz.LocaleKeyCoverage(); return Ok(new ApiOkResponse(l)); } #endif @@ -420,5 +420,22 @@ namespace AyaNova.Api.Controllers } +#if (DEBUG) + public class LocaleCoverageInfo + { + public List RequestedKeys { get; set; } + public int RequestedKeyCount { get; set; } + public List NotRequestedKeys { get; set; } + public int NotRequestedKeyCount { get; set; } + + public LocaleCoverageInfo() + { + RequestedKeys = new List(); + NotRequestedKeys = new List(); + } + + } +#endif + } } \ No newline at end of file diff --git a/server/AyaNova/biz/LocaleBiz.cs b/server/AyaNova/biz/LocaleBiz.cs index 6d2b9cf4..7e9d78d6 100644 --- a/server/AyaNova/biz/LocaleBiz.cs +++ b/server/AyaNova/biz/LocaleBiz.cs @@ -98,9 +98,24 @@ namespace AyaNova.Biz #if (DEBUG) - internal List RequestedKeyList() + internal AyaNova.Api.Controllers.LocaleController.LocaleCoverageInfo LocaleKeyCoverage() { - return ServerBootConfig.LocaleKeysRequested; + AyaNova.Api.Controllers.LocaleController.LocaleCoverageInfo L = new AyaNova.Api.Controllers.LocaleController.LocaleCoverageInfo(); + L.RequestedKeys = ServerBootConfig.LocaleKeysRequested; + L.RequestedKeys.Sort(); + var AllKeys = GetKeyList(); + foreach (string StockKey in AllKeys) + { + if (!L.RequestedKeys.Contains(StockKey)) + { + L.NotRequestedKeys.Add(StockKey); + } + } + L.NotRequestedKeys.Sort(); + L.RequestedKeyCount = L.RequestedKeys.Count; + L.NotRequestedKeyCount = L.NotRequestedKeys.Count; + + return L; } //Track requests for keys so we can determine which are being used and which are not diff --git a/test/raven-integration/Locale/RequestedLocaleKeys.cs b/test/raven-integration/Locale/RequestedLocaleKeys.cs index 4a658446..21104761 100644 --- a/test/raven-integration/Locale/RequestedLocaleKeys.cs +++ b/test/raven-integration/Locale/RequestedLocaleKeys.cs @@ -41,11 +41,18 @@ namespace raven_integration ((JArray)a.ObjectResponse["result"]).Count.Should().Be(2); //Now ensure there are at least two keys in the fetched keys array - a = await Util.GetAsync("Locale/RequestedKeyList", await Util.GetTokenAsync("ClientLimited")); + a = await Util.GetAsync("Locale/LocaleKeyCoverage", await Util.GetTokenAsync("ClientLimited")); Util.ValidateDataReturnResponseOk(a); Util.ValidateHTTPStatusCode(a, 200); + + var RequestedKeyCount = a.ObjectResponse["result"]["requestedKeyCount"].Value(); + RequestedKeyCount.Should().BeGreaterOrEqualTo(2); + var NotRequestedKeyCount = a.ObjectResponse["result"]["notRequestedKeyCount"].Value(); + NotRequestedKeyCount.Should().BeGreaterThan(1);//For now at least, once we have this dialed in it should be zero ultimately + //there should be dozens of keys but at times there might only be a few during development so at least verify there is more than one - ((JArray)a.ObjectResponse["result"]).Count.Should().BeGreaterOrEqualTo(2); + ((JArray)a.ObjectResponse["result"]["requestedKeys"]).Count.Should().Be(RequestedKeyCount); + ((JArray)a.ObjectResponse["result"]["notRequestedKeys"]).Count.Should().Be(NotRequestedKeyCount); } }