mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Move filters chart to ChartJS.
This commit is contained in:
@@ -131,36 +131,11 @@ namespace DiscImageChef.Server.Controllers
|
||||
}
|
||||
|
||||
if(ctx.Commands.Any())
|
||||
{
|
||||
ViewBag.repCommands = ctx.Commands.OrderBy(c => c.Name).ToList();
|
||||
|
||||
decimal totalCommandCount = ctx.Commands.Sum(o => o.Count);
|
||||
|
||||
ViewData["commandsPieData"] = ctx.Commands.Select(command => new PieSeriesData
|
||||
{
|
||||
Name = command.Name, Y = (double?)(command.Count / totalCommandCount),
|
||||
Sliced = command.Name == "analyze", Selected = command.Name == "analyze"
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
if(ctx.Filters.Any())
|
||||
{
|
||||
ViewBag.repFilters = ctx.Filters.OrderBy(filter => filter.Name).ToList();
|
||||
|
||||
List<PieSeriesData> filtersPieData = new List<PieSeriesData>();
|
||||
|
||||
decimal totalFiltersCount = ctx.Filters.Sum(o => o.Count);
|
||||
|
||||
foreach(Filter filter in ctx.Filters.ToList())
|
||||
filtersPieData.Add(new PieSeriesData
|
||||
{
|
||||
Name = filter.Name, Y = (double?)(filter.Count / totalFiltersCount),
|
||||
Sliced = filter.Name == "No filter", Selected = filter.Name == "No filter"
|
||||
});
|
||||
|
||||
ViewData["filtersPieData"] = filtersPieData;
|
||||
}
|
||||
|
||||
if(ctx.MediaFormats.Any())
|
||||
{
|
||||
ViewBag.repMediaImages = ctx.MediaFormats.OrderBy(filter => filter.Name).ToList();
|
||||
@@ -584,5 +559,23 @@ namespace DiscImageChef.Server.Controllers
|
||||
|
||||
return Json(result);
|
||||
}
|
||||
|
||||
public IActionResult GetFiltersData()
|
||||
{
|
||||
string[][] result =
|
||||
{
|
||||
ctx.Filters.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(),
|
||||
ctx.Filters.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.Filters.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString();
|
||||
|
||||
return Json(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user