Aggiornamento statistiche con dati x macchina chiamante
This commit is contained in:
@@ -26,6 +26,13 @@ namespace MP.Data.Services.Utils
|
||||
/// <returns></returns>
|
||||
Task<Dictionary<string, List<StatDataDTO>>> GetParetoStatsWeekAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce un dizionario di elaborazioni di tipo Pareto su orizzonte giornaliero
|
||||
/// Ogni elaborazione contiene Dictionary in forma pareto per una data statistica
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<Dictionary<string, List<StatDataDTO>>> GetParetoStatsDayAsync(int numDay);
|
||||
|
||||
/// <summary>
|
||||
/// Recupera il range di periodi valido per le chiamate aggregate.
|
||||
/// Utilizza la cache automaticamente.
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace MP.Data.Services.Utils
|
||||
/// <inheritdoc />
|
||||
public async Task<Dictionary<string, List<StatDataDTO>>> GetParetoStatsWeekAsync()
|
||||
{
|
||||
return await TraceAsync($"{_className}.GetDailyParetoStats", async (activity) =>
|
||||
return await TraceAsync($"{_className}.GetParetoStatsWeekAsync", async (activity) =>
|
||||
{
|
||||
return await GetOrSetCacheAsync(
|
||||
$"{_redisBaseKey}:{_className}:ParetoWeek",
|
||||
@@ -53,6 +53,18 @@ namespace MP.Data.Services.Utils
|
||||
);
|
||||
});
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public async Task<Dictionary<string, List<StatDataDTO>>> GetParetoStatsDayAsync(int numDay)
|
||||
{
|
||||
return await TraceAsync($"{_className}.GetParetoStatsDayAsync", async (activity) =>
|
||||
{
|
||||
return await GetOrSetCacheAsync(
|
||||
$"{_redisBaseKey}:{_className}:ParetoDay",
|
||||
async () => await GetParetoMaccAsync(numDay),
|
||||
LongCache
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<DtUtils.Periodo> GetRangeAsync()
|
||||
@@ -123,6 +135,35 @@ namespace MP.Data.Services.Utils
|
||||
return result;
|
||||
}
|
||||
|
||||
protected async Task<Dictionary<string, List<StatDataDTO>>> GetParetoMaccAsync(int numDay)
|
||||
{
|
||||
Dictionary<string, List<StatDataDTO>> result = new();
|
||||
DateTime oggi = DateTime.Today;
|
||||
var rawData = await GetFiltAsync(oggi.AddDays(-numDay), oggi);
|
||||
// calcolo le varie statistiche...
|
||||
var pDestRequest = rawData.GroupBy(x => x.MachineId)
|
||||
.Select(g => new StatDataDTO
|
||||
{
|
||||
Label = g.Key,
|
||||
Value = g.Sum(x => x.RequestCount)
|
||||
})
|
||||
.OrderByDescending(x => x.Value)
|
||||
.ToList();
|
||||
result.Add("Mach.Request (#)", pDestRequest);
|
||||
|
||||
var pDestDuration = rawData.GroupBy(x => x.MachineId)
|
||||
.Select(g => new StatDataDTO
|
||||
{
|
||||
Label = g.Key,
|
||||
Value = g.Sum(x => x.RequestCount * x.AvgDuration)
|
||||
})
|
||||
.OrderByDescending(x => x.Value)
|
||||
.ToList();
|
||||
result.Add("Mach.Duration (ms)", pDestDuration);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
@@ -196,25 +196,25 @@ namespace MP.Data.Services.Utils
|
||||
.ToList();
|
||||
result.Add("Type.Duration (ms)", pTypeDuration);
|
||||
|
||||
// calcolo le varie statistiche COMPOSTE...
|
||||
var pDestTypeRequest = rawData.GroupBy(x => new { x.Destination, x.Type })
|
||||
.Select(g => new StatDataDTO
|
||||
{
|
||||
Label = $"{g.Key.Destination}.{g.Key.Type}",
|
||||
Value = g.Sum(x => x.RequestCount)
|
||||
})
|
||||
.OrderByDescending(x => x.Value)
|
||||
.ToList();
|
||||
result.Add("DestType.Request (#)", pDestTypeRequest);
|
||||
var pDestTypeDuration = rawData.GroupBy(x => new { x.Destination, x.Type })
|
||||
.Select(g => new StatDataDTO
|
||||
{
|
||||
Label = $"{g.Key.Destination}.{g.Key.Type}",
|
||||
Value = g.Sum(x => x.RequestCount * x.AvgDuration)
|
||||
})
|
||||
.OrderByDescending(x => x.Value)
|
||||
.ToList();
|
||||
result.Add("DestType.Duration (ms)", pDestTypeDuration);
|
||||
//// calcolo le varie statistiche COMPOSTE...
|
||||
//var pDestTypeRequest = rawData.GroupBy(x => new { x.Destination, x.Type })
|
||||
// .Select(g => new StatDataDTO
|
||||
// {
|
||||
// Label = $"{g.Key.Destination}.{g.Key.Type}",
|
||||
// Value = g.Sum(x => x.RequestCount)
|
||||
// })
|
||||
// .OrderByDescending(x => x.Value)
|
||||
// .ToList();
|
||||
//result.Add("DestType.Request (#)", pDestTypeRequest);
|
||||
//var pDestTypeDuration = rawData.GroupBy(x => new { x.Destination, x.Type })
|
||||
// .Select(g => new StatDataDTO
|
||||
// {
|
||||
// Label = $"{g.Key.Destination}.{g.Key.Type}",
|
||||
// Value = g.Sum(x => x.RequestCount * x.AvgDuration)
|
||||
// })
|
||||
// .OrderByDescending(x => x.Value)
|
||||
// .ToList();
|
||||
//result.Add("DestType.Duration (ms)", pDestTypeDuration);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -98,6 +98,9 @@ namespace MP.IOC.Components.Pages
|
||||
[Inject]
|
||||
private IStatsDetailService SDetService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
private IStatsAggrService SAggService { get; set; } = null!;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
@@ -211,6 +214,12 @@ namespace MP.IOC.Components.Pages
|
||||
private async Task ReloadData()
|
||||
{
|
||||
ParetoDay = await SDetService.GetParetoStatsDayAsync();
|
||||
//calcolo le statistiche aggregate e le aggiungo
|
||||
var machDay = await SAggService.GetParetoStatsDayAsync(0);
|
||||
foreach (var item in machDay)
|
||||
{
|
||||
ParetoDay.TryAdd(item.Key, item.Value.Where(x => x.Label != "ALL").ToList());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -137,16 +137,16 @@
|
||||
<div class="col-3">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item active d-flex justify-content-between align-items-start">
|
||||
<b>Call Processed</b>
|
||||
<b>Daily Call Processed</b>
|
||||
</li>
|
||||
@foreach (var item in ListGlobalCall)
|
||||
{
|
||||
<li class="list-group-item d-flex justify-content-between align-items-start small py-1">
|
||||
<div>
|
||||
@($"{item.Hour:yyyy-MM-dd}") | <b>@item.Destination</b>
|
||||
@item.Label
|
||||
</div>
|
||||
<div class="">
|
||||
<b>@($"{item.RequestCount:N0}")</b>
|
||||
<b>@($"{item.Value:N0}")</b>
|
||||
</div>
|
||||
</li>
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace MP.IOC.Components.Pages
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private List<StatsAggregatedModel> ListGlobalCall = new();
|
||||
private List<StatDataDTO> ListGlobalCall = new();
|
||||
|
||||
private List<StatsDetailModel> ListParetoCall = new();
|
||||
|
||||
@@ -42,8 +42,8 @@ namespace MP.IOC.Components.Pages
|
||||
{
|
||||
DateTime oggi = DateTime.Today;
|
||||
DateTime adesso = DateTime.Now;
|
||||
var rawData = await StatsAggrService.GetFiltAsync(oggi.AddDays(-5), oggi);
|
||||
ListGlobalCall = rawData.OrderByDescending(x => x.Hour).ToList();
|
||||
var paretoDayCall = await StatsAggrService.GetParetoStatsDayAsync(0);
|
||||
ListGlobalCall = paretoDayCall["Mach.Duration (ms)"];
|
||||
ListParetoCall = await StatsDetService.GetParetoAsync(adesso.AddHours(-1), adesso, 10);
|
||||
paretoWeek = await StatsAggrService.GetParetoStatsWeekAsync();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>6.16.2604.2218</Version>
|
||||
<Version>6.16.2604.2219</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MP-IOC </i>
|
||||
<h4>Versione: 6.16.2604.2218</h4>
|
||||
<h4>Versione: 6.16.2604.2219</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2604.2218
|
||||
6.16.2604.2219
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2604.2218</version>
|
||||
<version>6.16.2604.2219</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user