This commit is contained in:
2018-09-18 14:50:13 +00:00
parent 39594f8de8
commit 0945f732b2
3 changed files with 48 additions and 9 deletions

View File

@@ -110,13 +110,13 @@ namespace AyaNova.Api.Controllers
#if (DEBUG)
/// <summary>
/// Get all unique Locale keys that were tracked
/// Get a coverage report of locale keys used versus unused
/// Required roles: Any
///
/// </summary>
/// <returns>List in alphabetical order of all unique locale keys requested since last server reboot</returns>
[HttpGet("RequestedKeyList")]
public ActionResult RequestedKeyList()
/// <returns>Report of all unique locale keys requested since last server reboot</returns>
[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<string> RequestedKeys { get; set; }
public int RequestedKeyCount { get; set; }
public List<string> NotRequestedKeys { get; set; }
public int NotRequestedKeyCount { get; set; }
public LocaleCoverageInfo()
{
RequestedKeys = new List<string>();
NotRequestedKeys = new List<string>();
}
}
#endif
}
}

View File

@@ -98,9 +98,24 @@ namespace AyaNova.Biz
#if (DEBUG)
internal List<string> 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

View File

@@ -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<int>();
RequestedKeyCount.Should().BeGreaterOrEqualTo(2);
var NotRequestedKeyCount = a.ObjectResponse["result"]["notRequestedKeyCount"].Value<int>();
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);
}
}