mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Put metrics in CouchDB, fix the proxy, fix list validation
This commit is contained in:
parent
98b7437aa8
commit
f446a967a0
@ -265,7 +265,7 @@ public class ValidateLists : IVerb
|
||||
private async Task<(RelativePath SmallImage, RelativePath LargeImage)> ProcessModlistImage(AbsolutePath reports, ModlistMetadata validatedList,
|
||||
CancellationToken token)
|
||||
{
|
||||
_logger.LogInformation("Processing Modlist Image");
|
||||
_logger.LogInformation("Processing Modlist Image for {MachineUrl}", validatedList.NamespacedName);
|
||||
var baseFolder = reports.Combine(validatedList.NamespacedName);
|
||||
baseFolder.CreateDirectory();
|
||||
|
||||
|
@ -46,7 +46,8 @@ public class DownloadDispatcher
|
||||
|
||||
public async Task<Archive> MaybeProxy(Archive a, CancellationToken token)
|
||||
{
|
||||
if (a.State is not IProxyable p) return a;
|
||||
var downloader = Downloader(a);
|
||||
if (downloader is not IProxyable p) return a;
|
||||
|
||||
var uri = p.UnParse(a.State);
|
||||
var newUri = await _wjClient.MakeProxyUrl(a, uri);
|
||||
@ -107,6 +108,10 @@ public class DownloadDispatcher
|
||||
{
|
||||
try
|
||||
{
|
||||
if (a.Name.Contains("HorseReplacer"))
|
||||
{
|
||||
|
||||
}
|
||||
a = await MaybeProxy(a, token);
|
||||
var downloader = Downloader(a);
|
||||
using var job = await _limiter.Begin($"Verifying {a.State.PrimaryKeyString}", -1, token);
|
||||
|
@ -75,15 +75,17 @@ public class MetricsController : ControllerBase
|
||||
if (value is "Default" or "untitled" || subject == "failed_download" || Guid.TryParse(value, out _))
|
||||
return new Result {Timestamp = date};
|
||||
|
||||
await _metricsStore.Ingest(new Metric
|
||||
await _db.AddAsync(new Metric
|
||||
{
|
||||
Timestamp = DateTime.UtcNow,
|
||||
Timestamp = date,
|
||||
Action = subject,
|
||||
Subject = value,
|
||||
MetricsKey = metricsKey,
|
||||
UserAgent = Request.Headers.UserAgent.FirstOrDefault() ?? "<unknown>",
|
||||
Ip = Request.Headers["cf-connecting-ip"].FirstOrDefault() ?? (Request.HttpContext.Connection.RemoteIpAddress?.ToString() ?? "")
|
||||
Ip = Request.Headers["cf-connecting-ip"].FirstOrDefault() ??
|
||||
(Request.HttpContext.Connection.RemoteIpAddress?.ToString() ?? "")
|
||||
});
|
||||
|
||||
return new Result {Timestamp = date};
|
||||
}
|
||||
|
||||
|
@ -101,6 +101,9 @@ public class Startup
|
||||
services.AddAllSingleton<ITokenProvider<WabbajackApiState>, WabbajackApiTokenProvider>();
|
||||
services.AddAllSingleton<IResource, IResource<DownloadDispatcher>>(s => new Resource<DownloadDispatcher>("Downloads", 12));
|
||||
services.AddAllSingleton<IResource, IResource<FileHashCache>>(s => new Resource<FileHashCache>("File Hashing", 12));
|
||||
services.AddAllSingleton<IResource, IResource<Wabbajack.Networking.WabbajackClientApi.Client>>(s =>
|
||||
new Resource<Wabbajack.Networking.WabbajackClientApi.Client>("Wabbajack Client", 4));
|
||||
|
||||
services.AddSingleton(s =>
|
||||
new FileHashCache(KnownFolders.AppDataLocal.Combine("Wabbajack", "GlobalHashCache.sqlite"),
|
||||
s.GetService<IResource<FileHashCache>>()!));
|
||||
@ -146,26 +149,26 @@ public class Startup
|
||||
// CouchDB
|
||||
services.AddSingleton(s =>
|
||||
{
|
||||
var settings = s.GetRequiredService<AppSettings>();
|
||||
var client = new CouchClient(settings.CesiDB.Endpoint, b =>
|
||||
var settings = s.GetRequiredService<AppSettings>().CesiDB;
|
||||
var client = new CouchClient(settings.Endpoint, b =>
|
||||
{
|
||||
b.UseBasicAuthentication("cesi", "password");
|
||||
b.UseBasicAuthentication(settings.Username, settings.Password);
|
||||
b.SetPropertyCase(PropertyCaseType.None);
|
||||
b.SetJsonNullValueHandling(NullValueHandling.Ignore);
|
||||
});
|
||||
return client.GetDatabase<Analyzed>("cesi");
|
||||
return client.GetDatabase<Analyzed>(settings.Database);
|
||||
});
|
||||
|
||||
services.AddSingleton(s =>
|
||||
{
|
||||
var settings = s.GetRequiredService<AppSettings>();
|
||||
var client = new CouchClient(settings.CesiDB.Endpoint, b =>
|
||||
var settings = s.GetRequiredService<AppSettings>().MetricsDB;
|
||||
var client = new CouchClient(settings.Endpoint, b =>
|
||||
{
|
||||
b.UseBasicAuthentication("wabbajack", "password");
|
||||
b.UseBasicAuthentication(settings.Username, settings.Password);
|
||||
b.SetPropertyCase(PropertyCaseType.None);
|
||||
b.SetJsonNullValueHandling(NullValueHandling.Ignore);
|
||||
});
|
||||
return client.GetDatabase<Metric>("cesi");
|
||||
return client.GetDatabase<Metric>(settings.Database);
|
||||
});
|
||||
|
||||
services.AddMvc();
|
||||
|
Loading…
Reference in New Issue
Block a user