diff --git a/MP.Core/DTO/ChartDataPointDto.cs b/MP.Core/DTO/ChartDataPointDto.cs deleted file mode 100644 index 087d2c6f..00000000 --- a/MP.Core/DTO/ChartDataPointDto.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MP.Core.DTO -{ - public class ChartDataPointDto - { - } -} diff --git a/MP.Core/DTO/ChartSeriesDto.cs b/MP.Core/DTO/ChartSeriesDto.cs deleted file mode 100644 index 98f134b0..00000000 --- a/MP.Core/DTO/ChartSeriesDto.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MP.Core.DTO -{ - internal class ChartSerieDTO - { - } -} diff --git a/MP.Core/MP.Core.csproj b/MP.Core/MP.Core.csproj index 687d58ca..ad90e90c 100644 --- a/MP.Core/MP.Core.csproj +++ b/MP.Core/MP.Core.csproj @@ -7,6 +7,8 @@ + + diff --git a/MP.Data/DTO/ChartSeriesDto.cs b/MP.Data/DTO/ChartSeriesDto.cs new file mode 100644 index 00000000..8fa40f29 --- /dev/null +++ b/MP.Data/DTO/ChartSeriesDto.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace MP.Data.DTO +{ + public class ChartSeriesDto + { + public string SeriesName { get; set; } + public List DataPoints { get; set; } + } +} diff --git a/MP.Data/Services/Utils/IStatsDetailService.cs b/MP.Data/Services/Utils/IStatsDetailService.cs index e8567d7e..c193815b 100644 --- a/MP.Data/Services/Utils/IStatsDetailService.cs +++ b/MP.Data/Services/Utils/IStatsDetailService.cs @@ -1,6 +1,7 @@ using EgwCoreLib.Utils; using MP.Core.DTO; using MP.Data.DbModels.Utils; +using MP.Data.DTO; using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -47,6 +48,13 @@ namespace MP.Data.Services.Utils /// Tipo filtrato Task GetRangeAsync(string sEnvir, string sType); + /// + /// Helper conversione dati dettaglio in statistiche da inviare a ChartJS + /// + /// + /// + List GetTimeSeriesData(List rawData); + /// /// Inserisce o aggiorna in batch le statistiche di dettaglio nel database. /// Opzionalmente elimina i record precedenti nel periodo specificato. diff --git a/MP.Data/Services/Utils/StatsDetailService.cs b/MP.Data/Services/Utils/StatsDetailService.cs index 19b482f5..b47cfd94 100644 --- a/MP.Data/Services/Utils/StatsDetailService.cs +++ b/MP.Data/Services/Utils/StatsDetailService.cs @@ -2,6 +2,7 @@ using Microsoft.Extensions.Configuration; using MP.Core.DTO; using MP.Data.DbModels.Utils; +using MP.Data.DTO; using MP.Data.Repository.Utils; using StackExchange.Redis; using System; @@ -98,6 +99,32 @@ namespace MP.Data.Services.Utils }); } + /// + public List GetTimeSeriesData(List rawData) + { + var series = rawData + .GroupBy(s => new { s.Destination, s.Type }) // Raggruppiamo per la chiave composta + .Select(group => new ChartSeriesDto + { + // Creiamo un nome leggibile per la legenda del grafico + SeriesName = $"{group.Key.Destination}|{group.Key.Type}", + + // Per ogni gruppo, creiamo la lista dei punti temporali + DataPoints = group + .OrderBy(p => p.Hour) // Fondamentale: l'asse X deve essere cronologico + .Select(p => new chartJsData.chartJsTSerie + { + x = p.Hour, + y = p.AvgDuration // La metrica richiesta + }) + .ToList() + }) + .OrderBy(s => s.SeriesName) // Opzionale: ordina le serie alfabeticamente + .ToList(); + + return series; + } + /// public async Task UpsertManyAsync(List listRecords, bool removeOld) { diff --git a/MP.IOC/Components/App.razor b/MP.IOC/Components/App.razor index 50f26fdc..4e40c9ab 100644 --- a/MP.IOC/Components/App.razor +++ b/MP.IOC/Components/App.razor @@ -21,8 +21,8 @@ @* *@ -@* - *@ + + diff --git a/MP.IOC/Components/ChartJS/MultiLine.razor b/MP.IOC/Components/ChartJS/MultiLine.razor index 3a926640..9cdcfa5a 100644 --- a/MP.IOC/Components/ChartJS/MultiLine.razor +++ b/MP.IOC/Components/ChartJS/MultiLine.razor @@ -89,7 +89,7 @@ responsive = true, scales = new { - yAxes = new + y = new { stacked = Stacked, type = "linear", @@ -102,14 +102,18 @@ suggestedMin = MinValue != MaxValue ? MinValue : "auto", suggestedMax = MinValue != MaxValue ? MaxValue : "auto" }, - xAxes = new + x = new { type = "time", + time = new + { + unit = "hour" // Forza l'unità temporale se i dati sono orari + }, distribution = "linear", } }, - Animation = false, - AspectRatio = AspRatio == 0 ? "auto" : $"{AspRatio}" + animation = false, + aspectRatio = AspRatio == 0 ? (object)null : AspRatio }, data = new { diff --git a/MP.IOC/Components/Pages/CallStats.razor b/MP.IOC/Components/Pages/CallStats.razor index 19cfae9f..8aeac068 100644 --- a/MP.IOC/Components/Pages/CallStats.razor +++ b/MP.IOC/Components/Pages/CallStats.razor @@ -63,18 +63,23 @@ else { @currDetail - timeserie selezionata x num call/tempo + if (tsDataDetail.Count == 0) + { +
← No data found
+ } + else + { +
+ @tsDataDetail.Count values + + @* *@ + + +
+ } } } - @*
- @foreach (var item in ParetoDay) - { -
- -
- } -
*@ diff --git a/MP.IOC/Components/Pages/CallStats.razor.cs b/MP.IOC/Components/Pages/CallStats.razor.cs index f4e18cd8..b25c8758 100644 --- a/MP.IOC/Components/Pages/CallStats.razor.cs +++ b/MP.IOC/Components/Pages/CallStats.razor.cs @@ -1,5 +1,8 @@ using Microsoft.AspNetCore.Components; using MP.Core.DTO; +using MP.Data; +using MP.Data.DbModels.Utils; +using MP.Data.DTO; using MP.Data.Services.Utils; namespace MP.IOC.Components.Pages @@ -32,8 +35,11 @@ namespace MP.IOC.Components.Pages private List currData = new(); + private string currId = ""; private string currHistId = ""; private string currPieId = ""; + private string currTsId = ""; + private string currTitle = ""; @@ -63,7 +69,7 @@ namespace MP.IOC.Components.Pages } [Inject] - private IStatsDetailService StatsDetService { get; set; } = null!; + private IStatsDetailService SDetService { get; set; } = null!; #endregion Private Properties @@ -71,13 +77,15 @@ namespace MP.IOC.Components.Pages private string CheckSelect(string curKey) { - return !string.IsNullOrEmpty(currHistId) && currHistId == curKey ? "active" : ""; + return !string.IsNullOrEmpty(currId) && currId == curKey ? "active" : ""; } private void DoReset() { + currId = ""; currHistId = ""; currPieId = ""; + currTsId = ""; currData = new(); } @@ -85,8 +93,10 @@ namespace MP.IOC.Components.Pages { if (ParetoDay.ContainsKey(reqKey)) { + currId = reqKey; currHistId = $"Bar_{reqKey}"; currPieId = $"Pie_{reqKey}"; + currTsId = $"TS_{reqKey}"; currTitle = $"Pareto | {reqKey}"; currData = ParetoDay[reqKey]; } @@ -94,7 +104,7 @@ namespace MP.IOC.Components.Pages private async Task ReloadData() { - ParetoDay = await StatsDetService.GetParetoStatsDayAsync(); + ParetoDay = await SDetService.GetParetoStatsDayAsync(); } /// @@ -137,7 +147,26 @@ namespace MP.IOC.Components.Pages currDetail = selDetail; // recupero dettaglio 7gg... DateTime adesso = DateTime.Now; - var detailList = await StatsDetService.GetFiltAsync(adesso.AddDays(-3), adesso, "", selDetail); + List rawData = await SDetService.GetFiltAsync(adesso.AddDays(-3), adesso, "", selDetail); + // conversione con grouping + tsData = rawData.Select(r => new chartJsData.chartJsTSerie() { x = r.Hour, y = (double)r.AvgDuration }) + .OrderBy(o => o.x) + .ToList(); + tsDataDetail = SDetService.GetTimeSeriesData(rawData); + lineTitles = tsDataDetail.Select(x => x.SeriesName).ToList(); + TSDataMulti = tsDataDetail.Select(x => x.DataPoints).ToList(); } + + private List LabelPlot + { + get => tsData.Select(r => $"{r.x:yyyy-MM-dd}").ToList(); + } + + private List tsDataDetail = new(); + + private List tsData = new List(); + + private List> TSDataMulti = new(); + private List lineTitles = new List(); } } \ No newline at end of file diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index a956c67b..f7ca4f05 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 6.16.2604.1014 + 6.16.2604.1016 diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index e1381c5b..9f14d510 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

Versione: 6.16.2604.1014

+

Versione: 6.16.2604.1016


Note di rilascio:
  • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index 17f1aa9a..7659c690 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2604.1014 +6.16.2604.1016 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index 8cae1c77..d8446449 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2604.1014 + 6.16.2604.1016 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