2020-01-18 22:09:32 +00:00
|
|
|
|
using System;
|
2020-03-10 20:41:45 +00:00
|
|
|
|
using System.Linq;
|
2020-01-18 22:09:32 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2020-01-08 04:41:50 +00:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2020-03-10 20:41:45 +00:00
|
|
|
|
using Wabbajack.BuildServer.Model.Models;
|
2020-01-08 04:41:50 +00:00
|
|
|
|
using Wabbajack.BuildServer.Models;
|
2020-01-18 22:09:32 +00:00
|
|
|
|
using Wabbajack.Common;
|
2020-01-08 04:41:50 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.BuildServer.Controllers
|
|
|
|
|
{
|
2020-01-10 02:06:11 +00:00
|
|
|
|
[ApiController]
|
2020-01-08 04:41:50 +00:00
|
|
|
|
public abstract class AControllerBase<T> : ControllerBase
|
|
|
|
|
{
|
2020-01-10 02:06:11 +00:00
|
|
|
|
protected readonly ILogger<T> Logger;
|
2020-03-10 20:41:45 +00:00
|
|
|
|
protected readonly SqlService SQL;
|
2020-01-08 04:41:50 +00:00
|
|
|
|
|
2020-04-05 21:15:01 +00:00
|
|
|
|
protected AControllerBase(ILogger<T> logger, SqlService sql)
|
2020-01-08 04:41:50 +00:00
|
|
|
|
{
|
|
|
|
|
Logger = logger;
|
2020-03-10 20:41:45 +00:00
|
|
|
|
SQL = sql;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected async Task Metric(string verb, string subject)
|
|
|
|
|
{
|
|
|
|
|
await SQL.IngestMetric(new Metric
|
|
|
|
|
{
|
2020-04-15 03:25:00 +00:00
|
|
|
|
MetricsKey = Request?.Headers[Consts.MetricsKeyHeader].FirstOrDefault() ?? "",
|
2020-03-10 20:41:45 +00:00
|
|
|
|
Subject = subject,
|
|
|
|
|
Action = verb,
|
|
|
|
|
Timestamp = DateTime.UtcNow
|
|
|
|
|
});
|
2020-01-08 04:41:50 +00:00
|
|
|
|
}
|
2020-01-18 22:09:32 +00:00
|
|
|
|
|
|
|
|
|
|
2020-01-08 04:41:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|