mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fix how we handle UTC dates with SQL
This commit is contained in:
parent
40640dff5a
commit
b99805fd58
@ -54,7 +54,7 @@ namespace Wabbajack.BuildServer.Controllers
|
||||
{
|
||||
var api = await NexusApiClient.Get(Request.Headers["apikey"].FirstOrDefault());
|
||||
result = await api.GetModInfo(game, ModId, false);
|
||||
await _sql.AddNexusModInfo(game, ModId, DateTime.UtcNow, result);
|
||||
await _sql.AddNexusModInfo(game, ModId, result.updated_time, result);
|
||||
|
||||
|
||||
method = "NOT_CACHED";
|
||||
@ -82,7 +82,9 @@ namespace Wabbajack.BuildServer.Controllers
|
||||
{
|
||||
var api = await NexusApiClient.Get(Request.Headers["apikey"].FirstOrDefault());
|
||||
result = await api.GetModFiles(game, ModId, false);
|
||||
await _sql.AddNexusModFiles(game, ModId, DateTime.UtcNow, result);
|
||||
var date = result.files.Select(f => f.uploaded_time).OrderByDescending(o => o).FirstOrDefault();
|
||||
date = date == default ? DateTime.UtcNow : date;
|
||||
await _sql.AddNexusModFiles(game, ModId, date, result);
|
||||
|
||||
method = "NOT_CACHED";
|
||||
Interlocked.Increment(ref ForwardCount);
|
||||
|
@ -17,6 +17,23 @@ namespace Wabbajack.Server.DataLayer
|
||||
SqlMapper.AddTypeHandler(new JsonMapper<CDNFileDefinition>());
|
||||
SqlMapper.AddTypeHandler(new VersionMapper());
|
||||
SqlMapper.AddTypeHandler(new GameMapper());
|
||||
SqlMapper.AddTypeHandler(new DateTimeHandler());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Needed to make sure dates are all in UTC format
|
||||
/// </summary>
|
||||
private class DateTimeHandler : SqlMapper.TypeHandler<DateTime>
|
||||
{
|
||||
public override void SetValue(IDbDataParameter parameter, DateTime value)
|
||||
{
|
||||
parameter.Value = value;
|
||||
}
|
||||
|
||||
public override DateTime Parse(object value)
|
||||
{
|
||||
return DateTime.SpecifyKind((DateTime)value, DateTimeKind.Utc);
|
||||
}
|
||||
}
|
||||
|
||||
class JsonMapper<T> : SqlMapper.TypeHandler<T>
|
||||
|
Loading…
Reference in New Issue
Block a user