public async Task <ActionResult> MemorySpark(string id) { var chart = GetSparkChart(); var dataPoints = (await DashboardData.GetMemoryUtilization(id, start: DateTime.UtcNow.AddHours(-SparkHours), end: null, pointCount: (int)chart.Width.Value)).ToList(); var maxMem = dataPoints.Max(mp => mp.TotalMemory).GetValueOrDefault(); var maxGB = (int)Math.Ceiling(maxMem / _gb); var area = GetSparkChartArea(maxMem + (maxGB / 8) * _gb); var used = GetSparkSeries("Used"); chart.Series.Add(used); foreach (var mp in dataPoints) { if (mp.AvgMemoryUsed.HasValue) { used.Points.Add(new DataPoint(mp.DateTime.ToOADate(), mp.AvgMemoryUsed.Value)); } } chart.ChartAreas.Add(area); return(chart.ToResult()); }
public async Task <ActionResult> MemoryJson(string id, long start, long end, bool?summary = false) { var detailPoints = await DashboardData.GetMemoryUtilization(id, start.ToDateTime(), end.ToDateTime(), 1000); if (detailPoints == null) { return(JsonNotFound()); } return(Json(new { points = detailPoints.Select(p => new { date = p.DateTime.ToEpochTime(true), value = (int)(p.AvgMemoryUsed / 1024 / 1024 ?? 0) }), summary = summary.GetValueOrDefault(false) ? (await DashboardData.GetMemoryUtilization(id, null, null, 1000)).Select(p => new { date = p.DateTime.ToEpochTime(true), value = (int)(p.AvgMemoryUsed / 1024 / 1024 ?? 0) }) : null, builds = !BuildStatus.HasCachePrimed ? null : GetBuilds(id, start, end).Select(b => new { date = b.StartDate.ToEpochTime(true), text = GetFlagTooltip(b), link = b.WebUrl }) })); }