diff --git a/DiscImageChef.Server/Controllers/StatsController.cs b/DiscImageChef.Server/Controllers/StatsController.cs index 1966eb77..73cbeff5 100644 --- a/DiscImageChef.Server/Controllers/StatsController.cs +++ b/DiscImageChef.Server/Controllers/StatsController.cs @@ -143,34 +143,8 @@ namespace DiscImageChef.Server.Controllers ViewBag.repPartitions = ctx.Partitions.OrderBy(filter => filter.Name).ToList(); if(ctx.Filesystems.Any()) - { ViewBag.repFilesystems = ctx.Filesystems.OrderBy(filter => filter.Name).ToList(); - List filesystemsPieData = new List(); - - decimal totalFilesystemsCount = ctx.Filesystems.Sum(o => o.Count); - decimal top10FilesystemCount = 0; - - foreach(Filesystem filesystem in ctx.Filesystems.OrderByDescending(o => o.Count).Take(10)) - { - top10FilesystemCount += filesystem.Count; - - filesystemsPieData.Add(new PieSeriesData - { - Name = filesystem.Name, Y = (double?)(filesystem.Count / totalFilesystemsCount) - }); - } - - filesystemsPieData.Add(new PieSeriesData - { - Name = "Other", - Y = (double?)((totalFilesystemsCount - top10FilesystemCount) / totalFilesystemsCount), - Sliced = true, Selected = true - }); - - ViewData["filesystemsPieData"] = filesystemsPieData; - } - if(ctx.Medias.Any()) { realMedia = new List(); @@ -562,5 +536,23 @@ namespace DiscImageChef.Server.Controllers return Json(result); } + + public IActionResult GetFilesystemsData() + { + string[][] result = + { + ctx.Filesystems.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(), + ctx.Filesystems.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.Filesystems.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString(); + + return Json(result); + } } } \ No newline at end of file diff --git a/DiscImageChef.Server/Views/Stats/Index.cshtml b/DiscImageChef.Server/Views/Stats/Index.cshtml index ccac2987..77dec225 100644 --- a/DiscImageChef.Server/Views/Stats/Index.cshtml +++ b/DiscImageChef.Server/Views/Stats/Index.cshtml @@ -305,7 +305,8 @@ @if (ViewBag.repFilesystems != null) {
-
+
+
@@ -589,6 +590,11 @@ function DrawPartitionsPie(partitionsData) DrawPie("partitionsChart", `Top ${partitionsData[0].length} partitioning schemes found`, partitionsData[0], partitionsData[1]) } +function DrawFilesystemsPie(filesystemsData) +{ + DrawPie("filesystemsChart", `Top ${filesystemsData[0].length} filesystems found`, filesystemsData[0], filesystemsData[1]) +} + window.onload = () => { $.ajax({dataType: "json", url: "/Stats/GetOsData", success: DrawOsPie, cache:false}); $.ajax({dataType: "json", url: "/Stats/GetLinuxData", success: DrawLinuxPie, cache:false}); @@ -599,6 +605,7 @@ window.onload = () => { $.ajax({dataType: "json", url: "/Stats/GetFiltersData", success: DrawFiltersPie, cache:false}); $.ajax({dataType: "json", url: "/Stats/GetFormatsData", success: DrawFormatsPie, cache:false}); $.ajax({dataType: "json", url: "/Stats/GetPartitionsData", success: DrawPartitionsPie, cache:false}); + $.ajax({dataType: "json", url: "/Stats/GetFilesystemsData", success: DrawFilesystemsPie, cache:false}); } \ No newline at end of file