Update IOC x stats preliminari
This commit is contained in:
@@ -47,6 +47,34 @@ namespace MP.Data.Repository.Utils
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<List<StatsDetailModel>> GetParetoAsync(DateTime dtStart, DateTime dtEnd, int maxRec, string sDest = "", string sType = "")
|
||||
{
|
||||
await using var dbCtx = await CreateContextAsync();
|
||||
List<StatsDetailModel> answ = new List<StatsDetailModel>();
|
||||
|
||||
// recupero ed ordino per data-ora
|
||||
var query = dbCtx.DbSetStatsDet
|
||||
.Where(x => x.Hour >= dtStart && x.Hour <= dtEnd);
|
||||
|
||||
if (!string.IsNullOrEmpty(sDest))
|
||||
query = query.Where(x => x.Destination == sDest);
|
||||
|
||||
if (!string.IsNullOrEmpty(sType))
|
||||
query = query.Where(x => x.Type == sType);
|
||||
|
||||
answ = await query
|
||||
.AsNoTracking()
|
||||
.OrderByDescending(x => x.RequestCount)
|
||||
.ThenBy(x => x.Hour)
|
||||
.ThenBy(x => x.Destination)
|
||||
.ThenBy(x => x.Type)
|
||||
.Take(maxRec)
|
||||
.ToListAsync();
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<DtUtils.Periodo> GetRangeAsync(string sEnvir, string sType)
|
||||
{
|
||||
@@ -68,7 +96,6 @@ namespace MP.Data.Repository.Utils
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<int> UpsertManyAsync(List<StatsDetailModel> listRecords, bool removeOld)
|
||||
{
|
||||
@@ -161,6 +188,8 @@ namespace MP.Data.Repository.Utils
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#if false
|
||||
/// <inheritdoc />
|
||||
public async Task<int> UpsertManyAsyncOrig(List<StatsDetailModel> listRecords, bool removeOld)
|
||||
@@ -181,7 +210,6 @@ namespace MP.Data.Repository.Utils
|
||||
DateTime startDate = firstRec.Hour;
|
||||
DateTime endDate = lastRec.Hour;
|
||||
|
||||
|
||||
var items = await dbCtx.DbSetStatsDet
|
||||
.Where(x => x.Hour >= startDate && x.Hour <= endDate)
|
||||
.ToListAsync();
|
||||
@@ -209,11 +237,9 @@ namespace MP.Data.Repository.Utils
|
||||
await tx.RollbackAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
Reference in New Issue
Block a user