This commit is contained in:
@@ -80,27 +80,21 @@ namespace AyaNova.Api.Controllers
|
|||||||
MinuteMetrics = await ct.MetricMM.AsNoTracking().OrderBy(z => z.t).ToListAsync();
|
MinuteMetrics = await ct.MetricMM.AsNoTracking().OrderBy(z => z.t).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//split out into seperate arrays
|
|
||||||
//10 digits is epoch seconds
|
|
||||||
//List<Tuple<double, double>> cpu=new List<Tuple<double, double>>();
|
|
||||||
var cpu = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.CPU)).ToList();
|
|
||||||
|
|
||||||
|
|
||||||
if (maxRecords < MinuteMetrics.Count)
|
|
||||||
{
|
|
||||||
cpu = Util.DataUtil.LargestTriangleThreeBuckets(cpu, (int)maxRecords) as List<Tuple<double, double>>;
|
|
||||||
//downsample it here
|
|
||||||
;//https://github.com/sveinn-steinarsson/flot-downsample/
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//convert to efficient array of double pairs
|
|
||||||
var v = cpu.Select(z => new double[] { z.Item1, z.Item2 }).ToArray();
|
|
||||||
|
|
||||||
var ret = new
|
var ret = new
|
||||||
{
|
{
|
||||||
cpu = v
|
MetricMM = new
|
||||||
|
{
|
||||||
|
labels = MinuteMetrics.Select(z => new DateTimeOffset(z.t).ToUnixTimeSeconds()).ToArray(),
|
||||||
|
cpu = MinuteMetrics.Select(z => z.CPU).ToArray(),
|
||||||
|
gen0 = MinuteMetrics.Select(z => z.Gen0).ToArray(),
|
||||||
|
gen1 = MinuteMetrics.Select(z => z.Gen1).ToArray(),
|
||||||
|
gen2 = MinuteMetrics.Select(z => z.Gen2).ToArray(),
|
||||||
|
allocated = MinuteMetrics.Select(z => z.Allocated).ToArray(),
|
||||||
|
workingSet = MinuteMetrics.Select(z => z.WorkingSet).ToArray(),
|
||||||
|
privateBytes = MinuteMetrics.Select(z => z.PrivateBytes).ToArray()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
//Log
|
//Log
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.Metrics, AyaEvent.Retrieved), ct);
|
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.Metrics, AyaEvent.Retrieved), ct);
|
||||||
@@ -109,10 +103,61 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------
|
//------------
|
||||||
|
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"chartData": {
|
||||||
|
"labels": [
|
||||||
|
"sunday",
|
||||||
|
"monday",
|
||||||
|
"tuesday",
|
||||||
|
"wednesday",
|
||||||
|
"thursday",
|
||||||
|
"friday",
|
||||||
|
"saturday"
|
||||||
|
],
|
||||||
|
"thisWeek": [
|
||||||
|
20000,
|
||||||
|
14000,
|
||||||
|
12000,
|
||||||
|
15000,
|
||||||
|
18000,
|
||||||
|
19000,
|
||||||
|
22000
|
||||||
|
],
|
||||||
|
"lastWeek": [
|
||||||
|
19000,
|
||||||
|
10000,
|
||||||
|
14000,
|
||||||
|
14000,
|
||||||
|
15000,
|
||||||
|
22000,
|
||||||
|
24000
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// //split out into seperate arrays
|
||||||
|
// //10 digits is epoch seconds
|
||||||
|
// //List<Tuple<double, double>> cpu=new List<Tuple<double, double>>();
|
||||||
|
// var cpu = MinuteMetrics.Select(z => new Tuple<double, double>(new DateTimeOffset(z.t).ToUnixTimeSeconds(), z.CPU)).ToList();
|
||||||
|
|
||||||
|
// bool DownSampled=false;
|
||||||
|
// if (maxRecords < MinuteMetrics.Count)
|
||||||
|
// {
|
||||||
|
// cpu = Util.DataUtil.LargestTriangleThreeBuckets(cpu, (int)maxRecords) as List<Tuple<double, double>>;
|
||||||
|
// //downsample it here
|
||||||
|
// ;//https://github.com/sveinn-steinarsson/flot-downsample/
|
||||||
|
// DownSampled=true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //convert to efficient array of double pairs
|
||||||
|
// // var v = cpu.Select(z => new double[] { z.Item1, z.Item2 }).ToArray();
|
||||||
|
// var v = cpu.Select(z => new MetricItem { x= DateTimeOffset.FromUnixTimeSeconds((long)z.Item1), y=z.Item2 }).ToArray();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ namespace AyaNova.Biz
|
|||||||
private static double _cpu = 0;
|
private static double _cpu = 0;
|
||||||
|
|
||||||
#if(DEBUG)
|
#if(DEBUG)
|
||||||
private static TimeSpan tsOneMinute = new TimeSpan(0, 1, 0);
|
private static TimeSpan tsOneMinute = new TimeSpan(0, 0, 10);
|
||||||
#else
|
#else
|
||||||
private static TimeSpan tsOneMinute = new TimeSpan(0, 1, 0);
|
private static TimeSpan tsOneMinute = new TimeSpan(0, 1, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user