diff --git a/MP.Data/Services/Utils/StatsAggrService.cs b/MP.Data/Services/Utils/StatsAggrService.cs index 012031e9..f0a9f0c7 100644 --- a/MP.Data/Services/Utils/StatsAggrService.cs +++ b/MP.Data/Services/Utils/StatsAggrService.cs @@ -84,50 +84,47 @@ namespace MP.Data.Services.Utils /// public List GetTimeSeriesData(List rawData, bool groupMach, bool getCount) { + DateTime adesso = DateTime.Now; + List series = new(); // a seconda della richiesta cambio il group by... if (groupMach) { series = rawData - .GroupBy(s => new { s.Destination, s.MachineId }) // Raggruppiamo per la chiave composta + .GroupBy(s => new { s.Destination }) .Select(group => new ChartSeriesDto { - // Creiamo un nome leggibile per la legenda del grafico - SeriesName = $"{group.Key.Destination}|{group.Key.MachineId}", - - // Per ogni gruppo, creiamo la lista dei punti temporali + SeriesName = group.Key.Destination, DataPoints = group - .OrderBy(p => p.Hour) // Fondamentale: l'asse X deve essere cronologico + .OrderBy(p => p.Hour) .Select(p => new chartJsData.chartJsTSerie { x = p.Hour, - y = getCount ? p.RequestCount : p.AvgDuration * p.RequestCount // La metrica richiesta + y = (getCount ? 1 : p.AvgDuration) * p.RequestCount / (p.Hour.Date.Equals(adesso.Date) ? adesso.TimeOfDay.TotalHours : 24) }) .ToList() }) - .OrderBy(s => s.SeriesName) // Opzionale: ordina le serie alfabeticamente + .OrderBy(s => s.SeriesName) .ToList(); } else { series = rawData - .GroupBy(s => new { s.MachineId, s.Destination }) // Raggruppiamo per la chiave composta + .GroupBy(s => new { s.MachineId }) .Select(group => new ChartSeriesDto { - // Creiamo un nome leggibile per la legenda del grafico - SeriesName = $"{group.Key.MachineId}|{group.Key.Destination}", + SeriesName = group.Key.MachineId, - // Per ogni gruppo, creiamo la lista dei punti temporali DataPoints = group - .OrderBy(p => p.Hour) // Fondamentale: l'asse X deve essere cronologico + .OrderBy(p => p.Hour) .Select(p => new chartJsData.chartJsTSerie { x = p.Hour, - y = getCount ? p.RequestCount : p.AvgDuration // La metrica richiesta + y = (getCount ? 1 : p.AvgDuration) * p.RequestCount / (p.Hour.Date.Equals(adesso.Date) ? adesso.TimeOfDay.TotalHours : 24) }) .ToList() }) - .OrderBy(s => s.SeriesName) // Opzionale: ordina le serie alfabeticamente + .OrderBy(s => s.SeriesName) .ToList(); } @@ -192,6 +189,7 @@ namespace MP.Data.Services.Utils protected async Task>> GetParetoMaccAsync(int numDay) { + numDay = numDay > 1 ? numDay : 1; Dictionary> result = new(); DateTime oggi = DateTime.Today; var rawData = await GetFiltAsync(oggi.AddDays(-numDay), oggi); @@ -200,7 +198,7 @@ namespace MP.Data.Services.Utils .Select(g => new StatDataDTO { Label = g.Key, - Value = g.Sum(x => x.RequestCount) + Value = g.Sum(x => x.RequestCount) / numDay }) .OrderByDescending(x => x.Value) .ToList(); @@ -210,11 +208,11 @@ namespace MP.Data.Services.Utils .Select(g => new StatDataDTO { Label = g.Key, - Value = g.Sum(x => x.RequestCount * x.AvgDuration) + Value = g.Sum(x => x.RequestCount * x.AvgDuration) / numDay }) .OrderByDescending(x => x.Value) .ToList(); - result.Add("Mach.Duration (ms)", pDestDuration); + result.Add("Mach.Duration (tot ms)", pDestDuration); return result; } diff --git a/MP.IOC/Components/ChartJS/MultiLine.razor b/MP.IOC/Components/ChartJS/MultiLine.razor index e289ccb2..6224c9c0 100644 --- a/MP.IOC/Components/ChartJS/MultiLine.razor +++ b/MP.IOC/Components/ChartJS/MultiLine.razor @@ -9,7 +9,13 @@ public string Id { get; set; } = "MyTs"; [Parameter] - public List Titles { get; set; } = new List() { "Demo Line" }; + public double AspRatio { get; set; } = 0; + + [Parameter] + public List backColor { get; set; } = new List(); + + [Parameter] + public bool BeginAtZero { get; set; } = true; [Parameter] public List> DataTSList { get; set; } = null!; @@ -20,19 +26,6 @@ [Parameter] public List lineColor { get; set; } = new List(); - [Parameter] - public List backColor { get; set; } = new List(); - - [Parameter] - public double AspRatio { get; set; } = 0; - - [Parameter] - public bool Stepped { get; set; } = false; - - [Parameter] - public bool Stacked { get; set; } = false; - - [Parameter] public string MinValue { get; set; } = "0"; @@ -41,6 +34,18 @@ [Parameter] public int lTens { get; set; } = 0; + + [Parameter] + public bool ShowLegend { get; set; } = true; + + [Parameter] + public bool Stepped { get; set; } = false; + + [Parameter] + public bool Stacked { get; set; } = false; + + [Parameter] + public List Titles { get; set; } = new List() { "Demo Line" }; [Parameter] public string yScale { get; set; } = "linear"; @@ -96,8 +101,8 @@ { stacked = Stacked, type = yScale, - // type = "logarithmic", display = true, + beginAtZero = BeginAtZero, ticks = new { maxTicksLimit = 10 @@ -110,13 +115,20 @@ type = "time", time = new { - unit = "hour" // Forza l'unità temporale se i dati sono orari + unit = "hour" }, distribution = "linear", } }, animation = false, - aspectRatio = AspRatio == 0 ? (object)null : AspRatio + aspectRatio = AspRatio == 0 ? (object)null : AspRatio, + plugins = new + { + legend = new + { + display = ShowLegend + } + } }, data = new { diff --git a/MP.IOC/Components/Pages/CallStats.razor b/MP.IOC/Components/Pages/CallStats.razor index eff4482b..448c4e32 100644 --- a/MP.IOC/Components/Pages/CallStats.razor +++ b/MP.IOC/Components/Pages/CallStats.razor @@ -2,7 +2,7 @@
-

Current Call Stats (24h)

+

Current Stats

@@ -10,7 +10,7 @@
-
Avail Data
+
Avail Data (24h)
- +
} diff --git a/MP.IOC/Components/Pages/CallStats.razor.cs b/MP.IOC/Components/Pages/CallStats.razor.cs index 570881b2..177e6412 100644 --- a/MP.IOC/Components/Pages/CallStats.razor.cs +++ b/MP.IOC/Components/Pages/CallStats.razor.cs @@ -20,25 +20,28 @@ namespace MP.IOC.Components.Pages #region Private Fields + private bool beginAtZero = false; private List currData = new(); private string currDetail = ""; private string currHistId = ""; - private StatInfoDto? currStatSel = null; private string currPieId = ""; - + private StatInfoDto? currStatSel = null; private string currTitle = ""; private string currTsId = ""; + private bool lineStacked = false; private List lineTitles = new List(); private int numDays = 5; private List ParetoDay = new(); + private string scaleFormat = "linear"; + private bool showLegend = true; private List tsData = new List(); private List tsDataDetail = new(); @@ -95,10 +98,10 @@ namespace MP.IOC.Components.Pages } [Inject] - private IStatsDetailService SDetService { get; set; } = null!; + private IStatsAggrService SAggService { get; set; } = null!; [Inject] - private IStatsAggrService SAggService { get; set; } = null!; + private IStatsDetailService SDetService { get; set; } = null!; #endregion Private Properties @@ -122,6 +125,10 @@ namespace MP.IOC.Components.Pages { // salvo dati! currStatSel = currStat; + lineStacked = currStat.Grouping != StatInfoDto.AggrLevel.Method; + showLegend = currStat.Grouping == StatInfoDto.AggrLevel.Method; + beginAtZero = currStat.Grouping != StatInfoDto.AggrLevel.Method; + scaleFormat = currStat.Grouping == StatInfoDto.AggrLevel.Method ? "logarithmic" : "linear"; string reqKey = currStat.Title; currHistId = $"Bar_{reqKey}"; currPieId = $"Pie_{reqKey}"; @@ -261,6 +268,7 @@ namespace MP.IOC.Components.Pages // ...secondo tipo richiesto (macchina/server e duration/count) tsDataDetail = SAggService.GetTimeSeriesData(rawAggrData, grpMachine, isCount); break; + case StatInfoDto.AggrLevel.Method: // recupero dettaglio 7gg... List rawData = await SDetService.GetFiltAsync(adesso.AddDays(-numDays), adesso, "", selDetail); @@ -271,6 +279,7 @@ namespace MP.IOC.Components.Pages // ...secondo tipo richiesto (duration/count) tsDataDetail = SDetService.GetTimeSeriesData(rawData, isCount); break; + case StatInfoDto.AggrLevel.None: default: break; @@ -278,7 +287,6 @@ namespace MP.IOC.Components.Pages lineTitles = tsDataDetail.Select(x => x.SeriesName).ToList(); TSDataMulti = tsDataDetail.Select(x => x.DataPoints).ToList(); } - } #endregion Private Methods diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index 3e004ed0..594ff56b 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 8.16.2604.2818 + 8.16.2604.2907 diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index f998854e..14683919 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

Versione: 8.16.2604.2818

+

Versione: 8.16.2604.2907


Note di rilascio:
  • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index fccf3868..403fcf6f 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2604.2818 +8.16.2604.2907 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index 833e7c55..e0f943be 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2604.2818 + 8.16.2604.2907 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false