If chart lists are 10 or higher, introduce "Other" for the rest.

This commit is contained in:
2019-11-03 04:08:19 +00:00
parent 994c683564
commit 908eb91d3f

View File

@@ -500,7 +500,9 @@ namespace DiscImageChef.Server.Controllers
return Json(result); return Json(result);
} }
public IActionResult GetLinuxData() => Json(new[] public IActionResult GetLinuxData()
{
string[][] result =
{ {
ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()).OrderByDescending(o => o.Count). ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()).OrderByDescending(o => o.Count).
Take(10). Take(10).
@@ -509,9 +511,22 @@ namespace DiscImageChef.Server.Controllers
ToArray(), ToArray(),
ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()).OrderByDescending(o => o.Count). ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()).OrderByDescending(o => o.Count).
Take(10).Select(x => x.Count.ToString()).ToArray() Take(10).Select(x => x.Count.ToString()).ToArray()
}); };
public IActionResult GetMacOsData() => Json(new[] if(result[0].Length < 10)
return Json(result);
result[0][9] = "Other";
result[1][9] = (ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()).Sum(o => o.Count) -
result[1].Take(9).Sum(long.Parse)).ToString();
return Json(result);
}
public IActionResult GetMacOsData()
{
string[][] result =
{ {
ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()).OrderByDescending(o => o.Count). ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()).OrderByDescending(o => o.Count).
Take(10). Take(10).
@@ -520,17 +535,41 @@ namespace DiscImageChef.Server.Controllers
ToArray(), ToArray(),
ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()).OrderByDescending(o => o.Count). ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()).OrderByDescending(o => o.Count).
Take(10).Select(x => x.Count.ToString()).ToArray() Take(10).Select(x => x.Count.ToString()).ToArray()
}); };
public IActionResult GetWindowsData() => Json(new[] if(result[0].Length < 10)
return Json(result);
result[0][9] = "Other";
result[1][9] = (ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()).Sum(o => o.Count) -
result[1].Take(9).Sum(long.Parse)).ToString();
return Json(result);
}
public IActionResult GetWindowsData()
{ {
ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()).OrderByDescending(o => o.Count). string[][] result =
Take(10). {
ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()).
OrderByDescending(o => o.Count).Take(10).
Select(x => Select(x =>
$"{DetectOS.GetPlatformName(PlatformID.Win32NT, x.Version)}{(string.IsNullOrEmpty(x.Version) ? "" : " ")}{x.Version}"). $"{DetectOS.GetPlatformName(PlatformID.Win32NT, x.Version)}{(string.IsNullOrEmpty(x.Version) ? "" : " ")}{x.Version}").
ToArray(), ToArray(),
ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()).OrderByDescending(o => o.Count). ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()).
Take(10).Select(x => x.Count.ToString()).ToArray() 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.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()).Sum(o => o.Count) -
result[1].Take(9).Sum(long.Parse)).ToString();
return Json(result);
}
} }
} }