Merge remote-tracking branch 'erri/master' into polish-and-fixes

This commit is contained in:
Justin Swanson 2019-12-15 15:31:50 -06:00
commit 4285932ef9
9 changed files with 92 additions and 3 deletions

View File

@ -1,5 +1,9 @@
### Changelog
#### Version - 1.0 beta 6 - 12/14/2019
* Fixes for some strange steam library setups
* Implemented download/install counts
#### Version - 1.0 beta 5 - 12/14/2019
* Added LoversLab download support
* Nexus and LL logins now happen via a in-ap browser

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Alphaleonis.Win32.Filesystem;
using Nancy;
using Wabbajack.Common;
namespace Wabbajack.CacheServer
{
/// <summary>
/// Extremely
/// </summary>
public class Metrics : NancyModule
{
private static SemaphoreSlim _lockObject = new SemaphoreSlim(1);
public static async Task Log(params object[] args)
{
var msg = new[] {string.Join("\t", args.Select(a => a.ToString()))};
Utils.Log(msg.First());
await _lockObject.WaitAsync();
try
{
File.AppendAllLines("stats.tsv", msg);
}
finally
{
_lockObject.Release();
}
}
public Metrics() : base("/")
{
Get("/metrics/{Action}/{Value}", HandleMetrics);
}
private async Task<string> HandleMetrics(dynamic arg)
{
var date = DateTime.UtcNow;
await Log(date, arg.Action, arg.Value);
return date.ToString();
}
}
}

View File

@ -74,6 +74,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ListValidationService.cs" />
<Compile Include="Metrics.cs" />
<Compile Include="NexusCacheModule.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace Wabbajack.Common
{
public class Metrics
{
/// <summary>
/// This is all we track for metrics, action, and value. The action will be like
/// "downloaded", the value "Joe's list".
/// </summary>
/// <param name="action"></param>
/// <param name="value"></param>
public static async Task Send(string action, string value)
{
var client = new HttpClient();
try
{
await client.GetAsync($"http://build.wabbajack.org/metrics/{action}/{value}");
}
catch (Exception) { }
}
}
}

View File

@ -108,6 +108,7 @@
<Compile Include="FileExtractor.cs" />
<Compile Include="GameMetaData.cs" />
<Compile Include="GOGHandler.cs" />
<Compile Include="Metrics.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SplittingStream.cs" />
<Compile Include="StatusFeed\AErrorMessage.cs" />

View File

@ -39,6 +39,8 @@ namespace Wabbajack.Lib
protected override async Task<bool> _Begin(CancellationToken cancel)
{
if (cancel.IsCancellationRequested) return false;
var metric = Metrics.Send("begin_install", ModList.Name);
ConfigureProcessor(18, await RecommendQueueSize());
var game = ModList.GameType.MetaData();
@ -134,6 +136,8 @@ namespace Wabbajack.Lib
SetScreenSizeInPrefs();
UpdateTracker.NextStep("Installation complete! You may exit the program.");
var metric2 = Metrics.Send("finish_install", ModList.Name);
return true;
}

View File

@ -37,6 +37,7 @@ namespace Wabbajack.Lib
protected override async Task<bool> _Begin(CancellationToken cancel)
{
if (cancel.IsCancellationRequested) return false;
var metric = Metrics.Send("begin_install", ModList.Name);
MessageBox.Show(
"Vortex Support is still experimental and may produce unexpected results. " +
"If anything fails go to the special vortex support channels on the discord. @erri120#2285 " +
@ -84,8 +85,9 @@ namespace Wabbajack.Lib
if (cancel.IsCancellationRequested) return false;
await InstallSteamWorkshopItems();
//InstallIncludedDownloadMetas();
//InstallIncludedDownloadMetas();
var metric2 = Metrics.Send("finish_install", ModList.Name);
Info("Installation complete! You may exit the program.");
return true;
}

View File

@ -49,5 +49,5 @@ using System.Windows;
// 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.10.0")]
[assembly: AssemblyFileVersion("1.0.10.0")]
[assembly: AssemblyVersion("1.0.11.0")]
[assembly: AssemblyFileVersion("1.0.11.0")]

View File

@ -81,6 +81,7 @@ namespace Wabbajack
var sub = queue.Status.Select(i => i.ProgressPercent)
.Subscribe(percent => ProgressPercent = percent);
TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
var metric = Metrics.Send("downloading", Metadata.Title);
queue.QueueTask(async () =>
{
var downloader = DownloadDispatcher.ResolveArchive(Metadata.Links.Download);