diff --git a/CHANGELOG.md b/CHANGELOG.md index 027c640ac..3e2f507ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ ### Changelog +#### Version - 1.0 beta 7 - 12/15/2019 +* Fixed a regression with HTTP downloading introduced in beta 5 +* No longer show broken modlists in the gallery +* Add Stardew Valley support +* Add support for .dat extraction +* Several UI fixes + #### Version - 1.0 beta 6 - 12/14/2019 * Fixes for some strange steam library setups * Implemented download/install counts diff --git a/Wabbajack.CacheServer/Metrics.cs b/Wabbajack.CacheServer/Metrics.cs index 014136a19..140681d0a 100644 --- a/Wabbajack.CacheServer/Metrics.cs +++ b/Wabbajack.CacheServer/Metrics.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Alphaleonis.Win32.Filesystem; using Nancy; +using ReactiveUI; using Wabbajack.Common; namespace Wabbajack.CacheServer @@ -36,6 +37,9 @@ public static async Task Log(params object[] args) public Metrics() : base("/") { Get("/metrics/{Action}/{Value}", HandleMetrics); + Get("/metrics/chart/", HandleChart); + Get("/metrics/chart/{Action}/", HandleChart); + Get("/metrics/chart/{Action}/{Value}/", HandleChart); } private async Task HandleMetrics(dynamic arg) @@ -44,5 +48,73 @@ private async Task HandleMetrics(dynamic arg) await Log(date, arg.Action, arg.Value); return date.ToString(); } + + private static async Task GetData() + { + await _lockObject.WaitAsync(); + try + { + return File.ReadAllLines("stats.tsv"); + } + finally + { + _lockObject.Release(); + } + } + + private async Task HandleChart(dynamic arg) + { + var data = (await GetData()).Select(line => line.Split('\t')) + .Where(line => line.Length == 3) + .Select(line => new {date = DateTime.Parse(line[0]), Action = line[1], Value = line[2]}); + + // Remove guids / Default, which come from testing + data = data.Where(d => !Guid.TryParse(d.Value ?? "", out _) && (d.Value ?? "") != "Default"); + + if (arg?.Action != null) + data = data.Where(d => d.Action == arg.Action); + + + if (arg?.Value != null) + data = data.Where(d => d.Value.StartsWith(arg.Value)); + + var grouped_and_counted = data.GroupBy(d => d.date.ToString("yyyy-MM-dd")) + .OrderBy(d => d.Key) + .Select(d => new {Day = d.Key, Count = d.Count()}) + .ToList(); + + var sb = new StringBuilder(); + sb.Append(""); + sb.Append(""); + sb.Append(""); + sb.Append(""); + var response = (Response)sb.ToString(); + response.ContentType = "text/html"; + return response; + } } } diff --git a/Wabbajack/Properties/AssemblyInfo.cs b/Wabbajack/Properties/AssemblyInfo.cs index 25a017382..ff8c4d031 100644 --- a/Wabbajack/Properties/AssemblyInfo.cs +++ b/Wabbajack/Properties/AssemblyInfo.cs @@ -49,5 +49,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.11.0")] -[assembly: AssemblyFileVersion("1.0.11.0")] +[assembly: AssemblyVersion("1.0.12.0")] +[assembly: AssemblyFileVersion("1.0.12.0")]