mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-11-28 12:23:58 +01:00
AccountInfo history statistics query
This commit is contained in:
1 parent
ec8f434f42
commit
758aa10e55
18 files changed
+522
-28
No files matched your search
+42
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
|
||||
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
|
||||
using WotBlitzStatisticsPro.Logic.Pipeline;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
{
|
||||
public class FillPeriodStatisticsOperation : IOperation<IOperationContext>
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public FillPeriodStatisticsOperation(IMapper mapper)
|
||||
{
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
|
||||
public Task Invoke(IOperationContext context, Func<IOperationContext, Task> next)
|
||||
{
|
||||
var contextData = context.Get<IStatisticsPipelineData>();
|
||||
|
||||
if (contextData.History.Length > 1)
|
||||
{
|
||||
var diff = new AccountInfoHistory(context.Request.AccountId, contextData.History[0].LastBattleTime);
|
||||
|
||||
var historyLastIndex = contextData.History.Length - 1;
|
||||
|
||||
diff.Battles = contextData.History[0].Battles - contextData.History[historyLastIndex].Battles;
|
||||
diff.Wins = contextData.History[0].Wins - contextData.History[historyLastIndex].Wins;
|
||||
diff.DamageDealt = contextData.History[0].DamageDealt - contextData.History[historyLastIndex].DamageDealt;
|
||||
diff.Xp = contextData.History[0].Xp - contextData.History[historyLastIndex].Xp;
|
||||
|
||||
contextData.PeriodAccountStatistics = _mapper.Map<IStatistics, ShortStatistics>(diff);
|
||||
}
|
||||
|
||||
return next.Invoke(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user