Move commands chart to ChartJS.

This commit is contained in:
2019-11-03 04:21:29 +00:00
parent f289a344dd
commit 1c4390a9a0
2 changed files with 27 additions and 1 deletions

View File

@@ -44,6 +44,7 @@ using DiscImageChef.Server.Models;
using Highsoft.Web.Mvc.Charts;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using OperatingSystem = DiscImageChef.Server.Models.OperatingSystem;
using PlatformID = DiscImageChef.CommonTypes.Interop.PlatformID;
using Version = DiscImageChef.Server.Models.Version;
@@ -565,5 +566,23 @@ namespace DiscImageChef.Server.Controllers
return Json(result);
}
public IActionResult GetCommandsData()
{
string[][] result =
{
ctx.Commands.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(),
ctx.Commands.OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray()
};
if(result[0].Length < 10)
return Json(result);
result[0][9] = "Other";
result[1][9] = (ctx.Commands.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString();
return Json(result);
}
}
}