mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-28 21:00:05 +01:00
Nullable refernce types refactoring
This commit is contained in:
1 parent
e5c90e03d3
commit
e12734981b
85 files changed
+509
-351
No files matched your search
+7
-7
@@ -13,14 +13,14 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
|
||||
|
||||
public DateTime LastBattleSince { get; }
|
||||
|
||||
public AccountInfo DbAccountInfo { get; set; }
|
||||
public AccountInfo? DbAccountInfo { get; set; }
|
||||
|
||||
public IStatistics[] History { get; set; }
|
||||
public ShortStatistics OverallStatistics { get; set; }
|
||||
public ShortStatistics PeriodAccountStatistics { get; set; }
|
||||
public StatisticsDifference PeriodDifference { get; set; }
|
||||
public StatisticsDifference[] StatisticsHistory { get; set; }
|
||||
public IStatistics[]? History { get; set; }
|
||||
public ShortStatistics? OverallStatistics { get; set; }
|
||||
public ShortStatistics? PeriodAccountStatistics { get; set; }
|
||||
public StatisticsDifference? PeriodDifference { get; set; }
|
||||
public StatisticsDifference[]? StatisticsHistory { get; set; }
|
||||
|
||||
public AccountInfoHistoryResponse Response { get; set; }
|
||||
public AccountInfoHistoryResponse? Response { get; set; }
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -6,17 +6,17 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
|
||||
{
|
||||
public class AccountInformationPipelineContextData : IDatabasePipelineContextData
|
||||
{
|
||||
public AccountInfo AccountInfo { get; set; }
|
||||
public AccountInfo? AccountInfo { get; set; }
|
||||
|
||||
public AccountInfoHistory AccountInfoHistory { get; set; }
|
||||
public AccountInfoHistory? AccountInfoHistory { get; set; }
|
||||
|
||||
public List<TankInfo> Tanks { get; set; }
|
||||
public List<TankInfo>? Tanks { get; set; }
|
||||
|
||||
public Dictionary<long, TankInfoHistory> TanksHistory { get; set; }
|
||||
public Dictionary<long, TankInfoHistory>? TanksHistory { get; set; }
|
||||
|
||||
public AccountInfoResponse Response { get; set; }
|
||||
public AccountInfoResponse? Response { get; set; }
|
||||
|
||||
public AccountInfo DbAccountInfo { get; set; }
|
||||
public AccountInfo? DbAccountInfo { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -5,6 +5,6 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
|
||||
{
|
||||
public interface IDatabasePipelineContextData
|
||||
{
|
||||
AccountInfo DbAccountInfo { get; set; }
|
||||
AccountInfo? DbAccountInfo { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -4,15 +4,15 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
|
||||
{
|
||||
public interface IStatisticsPipelineData
|
||||
{
|
||||
IStatistics[] History { get; set; }
|
||||
IStatistics[]? History { get; set; }
|
||||
|
||||
ShortStatistics OverallStatistics { get; set; }
|
||||
ShortStatistics? OverallStatistics { get; set; }
|
||||
|
||||
public ShortStatistics PeriodAccountStatistics { get; set; }
|
||||
public ShortStatistics? PeriodAccountStatistics { get; set; }
|
||||
|
||||
public StatisticsDifference PeriodDifference { get; set; }
|
||||
public StatisticsDifference? PeriodDifference { get; set; }
|
||||
|
||||
public StatisticsDifference[] StatisticsHistory { get; set; }
|
||||
public StatisticsDifference[]? StatisticsHistory { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
{
|
||||
public class OperationContext : IOperationContext
|
||||
{
|
||||
private object _contextData;
|
||||
private object? _contextData;
|
||||
|
||||
|
||||
public OperationContext(AccountRequest request)
|
||||
@@ -21,7 +21,7 @@
|
||||
{
|
||||
_contextData ??= default(TContextData);
|
||||
|
||||
return (TContextData)_contextData;
|
||||
return (TContextData)_contextData!;
|
||||
}
|
||||
}
|
||||
}
|
||||
+30
-5
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using WotBlitzStatisticsPro.Common.Dictionaries;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.DataAccess;
|
||||
@@ -17,17 +18,31 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IDictionariesDataAccessor _dictionariesDataAccessor;
|
||||
private readonly ILogger<BuildAccountInfoResponseOperation> _logger;
|
||||
|
||||
public BuildAccountInfoResponseOperation(IMapper mapper, IDictionariesDataAccessor dictionariesDataAccessor)
|
||||
public BuildAccountInfoResponseOperation(
|
||||
IMapper mapper,
|
||||
IDictionariesDataAccessor dictionariesDataAccessor,
|
||||
ILogger<BuildAccountInfoResponseOperation> logger)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_dictionariesDataAccessor = dictionariesDataAccessor;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||
{
|
||||
var contextData = context.Get<AccountInformationPipelineContextData>();
|
||||
|
||||
if (contextData?.AccountInfo == null
|
||||
|| contextData?.Tanks == null
|
||||
|| contextData?.TanksHistory == null)
|
||||
{
|
||||
_logger.LogInformation(
|
||||
$"contextData or AccountInfo or Tanks or TanksHistory is null");
|
||||
return;
|
||||
}
|
||||
|
||||
contextData.Response = _mapper.Map<AccountInfo, AccountInfoResponse>(contextData.AccountInfo);
|
||||
contextData.Response = _mapper.Map(contextData.AccountInfoHistory, contextData.Response);
|
||||
|
||||
@@ -48,13 +63,23 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
opt.Items["language"] = context.Request.RequestLanguage;
|
||||
opt.AfterMap((src, dest) =>
|
||||
{
|
||||
dest.TankType = tankTypes.ContainsKey(dest.TankTypeId) ? tankTypes[dest.TankTypeId] : "-";
|
||||
dest.TankNation = nations.ContainsKey(dest.TankNationId) ? nations[dest.TankNationId] : "-";
|
||||
if(dest?.TankTypeId != null)
|
||||
{
|
||||
dest.TankType = tankTypes.ContainsKey(dest.TankTypeId)
|
||||
? tankTypes[dest.TankTypeId]
|
||||
: "-";
|
||||
}
|
||||
if(dest?.TankNationId != null)
|
||||
{
|
||||
dest.TankNation = nations.ContainsKey(dest.TankNationId)
|
||||
? nations[dest.TankNationId]
|
||||
: "-";
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
await next.Invoke(context);
|
||||
if (next != null) await next.Invoke(context);
|
||||
}
|
||||
|
||||
private static IVehiclesDictionary CreateStubVehicle()
|
||||
|
||||
+9
-2
@@ -17,9 +17,16 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
_dictionariesDataAccessor = dictionariesDataAccessor;
|
||||
}
|
||||
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||
{
|
||||
var contextData = context.Get<AccountInformationPipelineContextData>();
|
||||
if (contextData?.AccountInfo == null ||
|
||||
contextData?.AccountInfoHistory == null ||
|
||||
contextData?.Tanks == null ||
|
||||
contextData?.TanksHistory == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var tankIds = contextData.Tanks.Select(t => t.TankId).ToArray();
|
||||
var tankTires = await _dictionariesDataAccessor.GetTankTires(tankIds);
|
||||
@@ -36,7 +43,7 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
contextData.AccountInfoHistory.CalculateMiddleTier(contextData.TanksHistory.Values.ToList(), tankTires);
|
||||
contextData.AccountInfoHistory.CalculateWn7();
|
||||
|
||||
await next.Invoke(context);
|
||||
if (next != null) await next.Invoke(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -16,11 +16,11 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
}
|
||||
|
||||
|
||||
public Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
public Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||
{
|
||||
var contextData = context.Get<IStatisticsPipelineData>();
|
||||
|
||||
if (contextData.History == null ||
|
||||
if (contextData?.History == null ||
|
||||
contextData.History.Length == 0)
|
||||
{
|
||||
_logger.LogInformation(
|
||||
@@ -28,7 +28,7 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
return next.Invoke(context);
|
||||
return next != null ? next.Invoke(context) : Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -15,16 +15,16 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
public Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||
{
|
||||
var contextData = context.Get<AccountInformationPipelineContextData>();
|
||||
|
||||
if (contextData.DbAccountInfo == null ||
|
||||
contextData.DbAccountInfo.LastBattleTime < contextData.AccountInfo.LastBattleTime)
|
||||
contextData.DbAccountInfo.LastBattleTime < contextData.AccountInfo?.LastBattleTime)
|
||||
{
|
||||
return next.Invoke(context);
|
||||
if (next != null) return next.Invoke(context);
|
||||
}
|
||||
_logger.LogInformation($"Exiting without saving. Db LastBattleTime: {contextData.DbAccountInfo.LastBattleTime}, WG LastBattleTime: {contextData.AccountInfo.LastBattleTime}");
|
||||
_logger.LogInformation($"Exiting without saving. Db LastBattleTime: {contextData.DbAccountInfo?.LastBattleTime}, WG LastBattleTime: {contextData.AccountInfo?.LastBattleTime}");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -9,10 +9,15 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
{
|
||||
public class FillAccountInfoHistoryResponse : IOperation<IOperationContext>
|
||||
{
|
||||
public Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
public Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||
{
|
||||
var contextData = context.Get<AccountHistoryInformationPipelineContextData>();
|
||||
|
||||
if (contextData?.DbAccountInfo == null)
|
||||
{
|
||||
return next != null ? next.Invoke(context) : Task.CompletedTask;
|
||||
}
|
||||
|
||||
contextData.Response = new AccountInfoHistoryResponse
|
||||
{
|
||||
AccountId = context.Request.AccountId,
|
||||
@@ -24,7 +29,7 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
OverallAccountStatistics = contextData.OverallStatistics
|
||||
};
|
||||
|
||||
return next.Invoke(context);
|
||||
return next != null ? next.Invoke(context) : Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-3
@@ -17,13 +17,16 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
}
|
||||
|
||||
|
||||
public Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
public Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||
{
|
||||
var contextData = context.Get<IStatisticsPipelineData>();
|
||||
|
||||
contextData.OverallStatistics = _mapper.Map<IStatistics, ShortStatistics>(contextData.History[0]);
|
||||
if(contextData?.History != null)
|
||||
{
|
||||
contextData.OverallStatistics = _mapper.Map<IStatistics, ShortStatistics>(contextData.History[0]);
|
||||
}
|
||||
|
||||
return next.Invoke(context);
|
||||
return next != null ? next.Invoke(context) : Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
|
||||
using WotBlitzStatisticsPro.Logic.Calculations;
|
||||
@@ -10,11 +9,11 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
{
|
||||
public class FillPeriodDifferenceOperation : IOperation<IOperationContext>
|
||||
{
|
||||
public Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
public Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||
{
|
||||
var contextData = context.Get<IStatisticsPipelineData>();
|
||||
|
||||
if (contextData.History.Length > 1)
|
||||
if (contextData?.History != null && contextData.History.Length > 1)
|
||||
{
|
||||
contextData.PeriodDifference = new StatisticsDifference();
|
||||
var historyLastIndex = contextData.History.Length - 1;
|
||||
@@ -22,7 +21,7 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
contextData.PeriodDifference.FillDifference(contextData.History[0], contextData.History[historyLastIndex]);
|
||||
}
|
||||
|
||||
return next.Invoke(context);
|
||||
return next != null ? next.Invoke(context) : Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -18,11 +18,11 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
}
|
||||
|
||||
|
||||
public Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
public Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||
{
|
||||
var contextData = context.Get<IStatisticsPipelineData>();
|
||||
|
||||
if (contextData.History.Length > 1)
|
||||
if (contextData?.History != null && contextData.History.Length > 1)
|
||||
{
|
||||
var diff = new AccountInfoHistory(context.Request.AccountId, contextData.History[0].LastBattleTime);
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
contextData.PeriodAccountStatistics = _mapper.Map<IStatistics, ShortStatistics>(diff);
|
||||
}
|
||||
|
||||
return next.Invoke(context);
|
||||
return next != null ? next.Invoke(context) : Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -10,11 +10,11 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
{
|
||||
public class FillStatisticsDifferenceOperation : IOperation<IOperationContext>
|
||||
{
|
||||
public Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
public Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||
{
|
||||
var contextData = context.Get<IStatisticsPipelineData>();
|
||||
|
||||
if (contextData.History.Length > 1)
|
||||
if (contextData?.History != null && contextData.History.Length > 1)
|
||||
{
|
||||
contextData.StatisticsHistory = new StatisticsDifference[contextData.History.Length - 1];
|
||||
for (int i = 1; i < contextData.History.Length; i++)
|
||||
@@ -24,7 +24,7 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
}
|
||||
}
|
||||
|
||||
return next.Invoke(context);
|
||||
return next != null ? next.Invoke(context) : Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
-4
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
|
||||
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
|
||||
using WotBlitzStatisticsPro.Logic.Pipeline;
|
||||
@@ -13,29 +14,39 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
{
|
||||
private readonly IWargamingApiClient _wargamingApi;
|
||||
private readonly IMapper _mapper;
|
||||
private readonly ILogger<GetAccountInfoOperation> _logger;
|
||||
|
||||
public GetAccountInfoOperation(
|
||||
IWargamingApiClient wargamingApi,
|
||||
IMapper mapper)
|
||||
IMapper mapper,
|
||||
ILogger<GetAccountInfoOperation> logger)
|
||||
{
|
||||
_wargamingApi = wargamingApi;
|
||||
_mapper = mapper;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||
{
|
||||
var accountInfo = await
|
||||
_wargamingApi.GetPlayerAccountInfo(context.Request.AccountId, context.Request.RealmType, context.Request.RequestLanguage);
|
||||
|
||||
if (accountInfo == null)
|
||||
{
|
||||
_logger.LogInformation(
|
||||
$"Account not found for AccountId {context.Request.AccountId} and {context.Request.RealmType} realm");
|
||||
return;
|
||||
}
|
||||
|
||||
// Store info to AccountInfo and in AccountInfoHistory
|
||||
var contextData = context.Get<AccountInformationPipelineContextData>();
|
||||
contextData.AccountInfo = _mapper.Map<WotAccountInfo, AccountInfo>(accountInfo);
|
||||
contextData.AccountInfo.Realm = context.Request.RealmType;
|
||||
|
||||
contextData.AccountInfoHistory = new AccountInfoHistory(context.Request.AccountId, contextData.AccountInfo.LastBattleTime);
|
||||
_mapper.Map(accountInfo.Statistics.All, contextData.AccountInfoHistory);
|
||||
_mapper.Map(accountInfo.Statistics?.All, contextData.AccountInfoHistory);
|
||||
|
||||
await next.Invoke(context);
|
||||
if (next != null) await next.Invoke(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-5
@@ -1,12 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
|
||||
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
|
||||
using WotBlitzStatisticsPro.Logic.Pipeline;
|
||||
using WotBlitzStatisticsPro.WgApiClient;
|
||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
{
|
||||
@@ -14,26 +15,36 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
{
|
||||
private readonly IWargamingTanksApiClient _wargamingApi;
|
||||
private readonly IMapper _mapper;
|
||||
private readonly ILogger<GetTanksInfoOperation> _logger;
|
||||
|
||||
public GetTanksInfoOperation(
|
||||
IWargamingTanksApiClient wargamingApi,
|
||||
IMapper mapper)
|
||||
IMapper mapper,
|
||||
ILogger<GetTanksInfoOperation> logger)
|
||||
{
|
||||
_wargamingApi = wargamingApi;
|
||||
_mapper = mapper;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||
{
|
||||
var contextData = context.Get<AccountInformationPipelineContextData>();
|
||||
|
||||
var tanksInfo = await
|
||||
_wargamingApi.GetPlayerAccountTanksInfo(context.Request.AccountId, context.Request.RealmType, context.Request.RequestLanguage);
|
||||
|
||||
if (tanksInfo == null)
|
||||
{
|
||||
_logger.LogInformation(
|
||||
$"Tanks not found for AccountId {context.Request.AccountId} and {context.Request.RealmType} realm");
|
||||
return;
|
||||
}
|
||||
|
||||
contextData.Tanks = new List<TankInfo>();
|
||||
contextData.TanksHistory = new Dictionary<long, TankInfoHistory>();
|
||||
|
||||
tanksInfo.ForEach(tank =>
|
||||
tanksInfo.OrderByDescending(t => t.LastBattleTime).ToList().ForEach(tank =>
|
||||
{
|
||||
var tankInfo = new TankInfo(tank.AccountId, tank.TankId);
|
||||
_mapper.Map(tank, tankInfo);
|
||||
@@ -43,7 +54,7 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
contextData.TanksHistory[stat.TankId] = stat;
|
||||
});
|
||||
|
||||
await next.Invoke(context);
|
||||
if (next != null) await next.Invoke(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -15,12 +15,12 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
_accountDataAccessor = accountDataAccessor;
|
||||
}
|
||||
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||
{
|
||||
var contextData = context.Get<IDatabasePipelineContextData>();
|
||||
|
||||
contextData.DbAccountInfo = await _accountDataAccessor.ReadAccountInfo(context.Request.AccountId);
|
||||
await next.Invoke(context);
|
||||
if (next != null) await next.Invoke(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -17,12 +17,12 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
_accountDataAccessor = accountDataAccessor;
|
||||
}
|
||||
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||
{
|
||||
var contextData = context.Get<AccountHistoryInformationPipelineContextData>();
|
||||
|
||||
contextData.History = (await _accountDataAccessor.GetAccountHistory(context.Request.AccountId, contextData.LastBattleSince.ToUnixTimestamp())).ToArray();
|
||||
await next.Invoke(context);
|
||||
if (next != null) await next.Invoke(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-2
@@ -22,10 +22,18 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||
{
|
||||
var contextData = context.Get<AccountInformationPipelineContextData>();
|
||||
|
||||
if (contextData?.AccountInfo == null ||
|
||||
contextData?.AccountInfoHistory == null ||
|
||||
contextData?.Tanks == null ||
|
||||
contextData?.TanksHistory == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await _accountDataAccessor.AddOurUpdateAccountInfo(contextData.AccountInfo);
|
||||
await _accountDataAccessor.AddAccountInfoHistory(contextData.AccountInfoHistory);
|
||||
|
||||
@@ -46,7 +54,7 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
|
||||
_logger.LogInformation($"Updated account {contextData.AccountInfo.AccountId} and {tanksCount} tanks: {tankIdsAsString}");
|
||||
|
||||
await next.Invoke(context);
|
||||
if (next != null) await next.Invoke(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user