diff --git a/WotBlitzStatisticsPro.Common/Model/IStatistics.cs b/WotBlitzStatisticsPro.Common/Model/IStatistics.cs
new file mode 100644
index 0000000..d19fcce
--- /dev/null
+++ b/WotBlitzStatisticsPro.Common/Model/IStatistics.cs
@@ -0,0 +1,119 @@
+namespace WotBlitzStatisticsPro.Common.Model
+{
+ ///
+ /// Represents tank or account statistics
+ ///
+ public interface IStatistics
+ {
+ ///
+ /// LastBattle
+ ///
+ int LastBattleTime { get; }
+
+ ///
+ /// Battles count
+ ///
+ long? Battles { get; set; }
+
+ ///
+ /// Capture points
+ ///
+ long? CapturePoints { get; set; }
+
+ ///
+ /// Total damage amount
+ ///
+ long? DamageDealt { get; set; }
+
+ ///
+ /// Total amount of received damage
+ ///
+ long? DamageReceived { get; set; }
+
+ ///
+ /// Dropped capture points
+ ///
+ long? DroppedCapturePoints { get; set; }
+
+ ///
+ /// Total amount of frags
+ ///
+ long? Frags { get; set; }
+
+ ///
+ /// Total amount of fras grater ten 8 lvl
+ ///
+ long? Frags8P { get; set; }
+
+ ///
+ /// Total amount of hits
+ ///
+ long? Hits { get; set; }
+
+ ///
+ /// Total amount of losses
+ ///
+ long? Losses { get; set; }
+
+ ///
+ /// Max frags per battle
+ ///
+ long? MaxFrags { get; set; }
+
+ ///
+ /// Tank id, which kills max frags per battle
+ ///
+ long? MaxFragsTankId { get; set; }
+
+ ///
+ /// Max experience per battle
+ ///
+ long? MaxXp { get; set; }
+
+ ///
+ /// Tank Id which created max experience per battle
+ ///
+ long? MaxXpTankId { get; set; }
+
+ ///
+ /// Total shots count
+ ///
+ long? Shots { get; set; }
+
+ ///
+ /// Total count of spotted vehicles
+ ///
+ long? Spotted { get; set; }
+
+ ///
+ /// Total count of survived battles
+ ///
+ long? SurvivedBattles { get; set; }
+
+ ///
+ /// Total count of survived and winned battles
+ ///
+ long? WinAndSurvived { get; set; }
+
+ ///
+ /// Total wins count
+ ///
+ long? Wins { get; set; }
+
+ ///
+ /// Total amount of experience
+ ///
+ long? Xp { get; set; }
+
+ ///
+ /// Average tier
+ ///
+ double AvgTier { get; set; }
+
+ ///
+ /// Wn7 coefficient
+ ///
+ double Wn7 { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.DataAccess/Model/Accounts/AccountInfoHistory.cs b/WotBlitzStatisticsPro.DataAccess/Model/Accounts/AccountInfoHistory.cs
index 9853f07..a6e3975 100644
--- a/WotBlitzStatisticsPro.DataAccess/Model/Accounts/AccountInfoHistory.cs
+++ b/WotBlitzStatisticsPro.DataAccess/Model/Accounts/AccountInfoHistory.cs
@@ -1,9 +1,10 @@
using MongoDB.Bson.Serialization.Attributes;
+using WotBlitzStatisticsPro.Common.Model;
namespace WotBlitzStatisticsPro.DataAccess.Model.Accounts
{
- public class AccountInfoHistory
- {
+ public class AccountInfoHistory: IStatistics
+ {
public AccountInfoHistory(long accountId, int lastBattleTime)
{
AccountInfoHistoryId = new AccountInfoHistoryKey(accountId, lastBattleTime);
diff --git a/WotBlitzStatisticsPro.DataAccess/WargamingAccountDataAccessor.cs b/WotBlitzStatisticsPro.DataAccess/WargamingAccountDataAccessor.cs
index 446443d..faf5695 100644
--- a/WotBlitzStatisticsPro.DataAccess/WargamingAccountDataAccessor.cs
+++ b/WotBlitzStatisticsPro.DataAccess/WargamingAccountDataAccessor.cs
@@ -111,14 +111,24 @@ namespace WotBlitzStatisticsPro.DataAccess
.InsertOneAsync(tankInfoHistory);
}
- public Task> GetAccountHistory(long accountId, int lastBattleSince)
+ public async Task> GetAccountHistory(long accountId, int lastBattleSince)
{
- throw new System.NotImplementedException();
+ var history = await _database.GetCollection(AccountInfoHistoryCollectionName)
+ .FindAsync(Builders.Filter.Where(a =>
+ a.AccountInfoHistoryId.AccountId == accountId && a.AccountInfoHistoryId.LastBattleTime >= lastBattleSince),
+ new FindOptions { Sort = Builders.Sort.Descending(h => h.AccountInfoHistoryId.LastBattleTime)});
+ return history.ToList();
}
- public Task> GetTankHistory(long accountId, long tankId, int lastBattleSince)
+ public async Task> GetTankHistory(long accountId, long tankId, int lastBattleSince)
{
- throw new System.NotImplementedException();
+ var history = await _database.GetCollection(TankInfoHistoryCollectionName)
+ .FindAsync(
+ Builders.Filter.Where(t =>
+ t.TankInfoHistoryId.AccountId == accountId && t.TankId == tankId && t.TankInfoHistoryId.LastBattleTime >= lastBattleSince),
+ new FindOptions
+ {Sort = Builders.Sort.Descending(h => h.TankInfoHistoryId.LastBattleTime)});
+ return history.ToList();
}
}
}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/AccountHistoryInformationPipelineContextData.cs b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/AccountHistoryInformationPipelineContextData.cs
new file mode 100644
index 0000000..59e2b3e
--- /dev/null
+++ b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/AccountHistoryInformationPipelineContextData.cs
@@ -0,0 +1,26 @@
+using System;
+using WotBlitzStatisticsPro.Common.Model;
+using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
+
+namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
+{
+ public class AccountHistoryInformationPipelineContextData: IDatabasePipelineContextData, IStatisticsPipelineData
+ {
+ public AccountHistoryInformationPipelineContextData(DateTime lastBattleSince)
+ {
+ LastBattleSince = lastBattleSince;
+ }
+
+ public DateTime LastBattleSince { get; }
+
+ 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 AccountInfoHistoryResponse Response { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/HistoryInformationPipelineContextData.cs b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/HistoryInformationPipelineContextData.cs
deleted file mode 100644
index 54310ea..0000000
--- a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/HistoryInformationPipelineContextData.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using WotBlitzStatisticsPro.Common.Model;
-using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
-
-namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
-{
- public class HistoryInformationPipelineContextData: IDatabasePipelineContextData
- {
- public AccountInfo DbAccountInfo { get; set; }
-
-
- public AccountInfoHistoryResponse Response { get; set; }
- }
-}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/IStatisticsPipelineData.cs b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/IStatisticsPipelineData.cs
new file mode 100644
index 0000000..bf89ece
--- /dev/null
+++ b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/IStatisticsPipelineData.cs
@@ -0,0 +1,18 @@
+using WotBlitzStatisticsPro.Common.Model;
+
+namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
+{
+ public interface IStatisticsPipelineData
+ {
+ IStatistics[] History { get; set; }
+
+ ShortStatistics OverallStatistics { get; set; }
+
+ public ShortStatistics PeriodAccountStatistics { get; set; }
+
+ public StatisticsDifference PeriodDifference { get; set; }
+
+ public StatisticsDifference[] StatisticsHistory { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/CheckIfHistoryIsEmptyOperation.cs b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/CheckIfHistoryIsEmptyOperation.cs
new file mode 100644
index 0000000..d4c8d35
--- /dev/null
+++ b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/CheckIfHistoryIsEmptyOperation.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Logging;
+using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
+using WotBlitzStatisticsPro.Logic.Pipeline;
+
+namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
+{
+ public class CheckIfHistoryIsEmptyOperation : IOperation
+ {
+ private readonly ILogger _logger;
+
+ public CheckIfHistoryIsEmptyOperation(ILogger logger)
+ {
+ _logger = logger;
+ }
+
+
+ public Task Invoke(IOperationContext context, Func next)
+ {
+ var contextData = context.Get();
+
+ if (contextData.History == null ||
+ contextData.History.Length == 0)
+ {
+ _logger.LogInformation(
+ $"History request doesn't return any data");
+ return Task.CompletedTask;
+ }
+
+ return next.Invoke(context);
+ }
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/FillAccountInfoHistoryResponse.cs b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/FillAccountInfoHistoryResponse.cs
new file mode 100644
index 0000000..9afa183
--- /dev/null
+++ b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/FillAccountInfoHistoryResponse.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Threading.Tasks;
+using WotBlitzStatisticsPro.Common.Model;
+using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
+using WotBlitzStatisticsPro.Logic.Calculations;
+using WotBlitzStatisticsPro.Logic.Pipeline;
+
+namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
+{
+ public class FillAccountInfoHistoryResponse : IOperation
+ {
+ public Task Invoke(IOperationContext context, Func next)
+ {
+ var contextData = context.Get();
+
+ contextData.Response = new AccountInfoHistoryResponse
+ {
+ AccountId = context.Request.AccountId,
+ CreatedAt = contextData.DbAccountInfo.CreatedAt.ToDateTime(),
+ Nickname = contextData.DbAccountInfo.Nickname,
+ PeriodDifference = contextData.PeriodDifference,
+ StatisticsHistory = contextData.StatisticsHistory,
+ PeriodAccountStatistics = contextData.PeriodAccountStatistics,
+ OverallAccountStatistics = contextData.OverallStatistics
+ };
+
+ return next.Invoke(context);
+ }
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/FillOverallStatisticsOperation.cs b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/FillOverallStatisticsOperation.cs
new file mode 100644
index 0000000..410e8dc
--- /dev/null
+++ b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/FillOverallStatisticsOperation.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Threading.Tasks;
+using AutoMapper;
+using WotBlitzStatisticsPro.Common.Model;
+using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
+using WotBlitzStatisticsPro.Logic.Pipeline;
+
+namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
+{
+ public class FillOverallStatisticsOperation : IOperation
+ {
+ private readonly IMapper _mapper;
+
+ public FillOverallStatisticsOperation(IMapper mapper)
+ {
+ _mapper = mapper;
+ }
+
+
+ public Task Invoke(IOperationContext context, Func next)
+ {
+ var contextData = context.Get();
+
+ contextData.OverallStatistics = _mapper.Map(contextData.History[0]);
+
+ return next.Invoke(context);
+ }
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/FillPeriodDifferenceOperation.cs b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/FillPeriodDifferenceOperation.cs
new file mode 100644
index 0000000..7bbace2
--- /dev/null
+++ b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/FillPeriodDifferenceOperation.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Threading.Tasks;
+using AutoMapper;
+using WotBlitzStatisticsPro.Common.Model;
+using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
+using WotBlitzStatisticsPro.Logic.Calculations;
+using WotBlitzStatisticsPro.Logic.Pipeline;
+
+namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
+{
+ public class FillPeriodDifferenceOperation : IOperation
+ {
+ public Task Invoke(IOperationContext context, Func next)
+ {
+ var contextData = context.Get();
+
+ if (contextData.History.Length > 1)
+ {
+ contextData.PeriodDifference = new StatisticsDifference();
+ var historyLastIndex = contextData.History.Length - 1;
+
+ contextData.PeriodDifference.FillDifference(contextData.History[0], contextData.History[historyLastIndex]);
+ }
+
+ return next.Invoke(context);
+ }
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/FillPeriodStatisticsOperation.cs b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/FillPeriodStatisticsOperation.cs
new file mode 100644
index 0000000..5ea6093
--- /dev/null
+++ b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/FillPeriodStatisticsOperation.cs
@@ -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
+ {
+ private readonly IMapper _mapper;
+
+ public FillPeriodStatisticsOperation(IMapper mapper)
+ {
+ _mapper = mapper;
+ }
+
+
+ public Task Invoke(IOperationContext context, Func next)
+ {
+ var contextData = context.Get();
+
+ 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(diff);
+ }
+
+ return next.Invoke(context);
+ }
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/FillStatisticsDifferenceOperation.cs b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/FillStatisticsDifferenceOperation.cs
new file mode 100644
index 0000000..5485669
--- /dev/null
+++ b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/FillStatisticsDifferenceOperation.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using WotBlitzStatisticsPro.Common.Model;
+using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
+using WotBlitzStatisticsPro.Logic.Calculations;
+using WotBlitzStatisticsPro.Logic.Pipeline;
+
+namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
+{
+ public class FillStatisticsDifferenceOperation : IOperation
+ {
+ public Task Invoke(IOperationContext context, Func next)
+ {
+ var contextData = context.Get();
+
+ if (contextData.History.Length > 1)
+ {
+ contextData.StatisticsHistory = new StatisticsDifference[contextData.History.Length - 1];
+ for (int i = 1; i < contextData.History.Length; i++)
+ {
+ contextData.StatisticsHistory[i - 1] = new StatisticsDifference();
+ contextData.StatisticsHistory[i - 1].FillDifference(contextData.History[i - 1], contextData.History[i]);
+ }
+ }
+
+ return next.Invoke(context);
+ }
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/ReadAccountInfoHistoryFromDbOperation.cs b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/ReadAccountInfoHistoryFromDbOperation.cs
new file mode 100644
index 0000000..97a02bf
--- /dev/null
+++ b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/Operations/ReadAccountInfoHistoryFromDbOperation.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using WotBlitzStatisticsPro.DataAccess;
+using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
+using WotBlitzStatisticsPro.Logic.Calculations;
+using WotBlitzStatisticsPro.Logic.Pipeline;
+
+namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
+{
+ public class ReadAccountInfoHistoryFromDbOperation : IOperation
+ {
+ private readonly IWargamingAccountDataAccessor _accountDataAccessor;
+
+ public ReadAccountInfoHistoryFromDbOperation(IWargamingAccountDataAccessor accountDataAccessor)
+ {
+ _accountDataAccessor = accountDataAccessor;
+ }
+
+ public async Task Invoke(IOperationContext context, Func next)
+ {
+ var contextData = context.Get();
+
+ contextData.History = (await _accountDataAccessor.GetAccountHistory(context.Request.AccountId, contextData.LastBattleSince.ToUnixTimestamp())).ToArray();
+ await next.Invoke(context);
+ }
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/Calculations/DateTimeHelper.cs b/WotBlitzStatisticsPro.Logic/Calculations/DateTimeHelper.cs
index 8ff23c8..27b3595 100644
--- a/WotBlitzStatisticsPro.Logic/Calculations/DateTimeHelper.cs
+++ b/WotBlitzStatisticsPro.Logic/Calculations/DateTimeHelper.cs
@@ -12,6 +12,12 @@ namespace WotBlitzStatisticsPro.Logic.Calculations
return dtDateTime;
}
+ public static int ToUnixTimestamp(this DateTime date)
+ {
+ var diff = date - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
+ return Convert.ToInt32(diff.TotalSeconds);
+ }
+
}
}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/Calculations/StatisticsHelper.cs b/WotBlitzStatisticsPro.Logic/Calculations/StatisticsHelper.cs
new file mode 100644
index 0000000..fa8a920
--- /dev/null
+++ b/WotBlitzStatisticsPro.Logic/Calculations/StatisticsHelper.cs
@@ -0,0 +1,77 @@
+using WotBlitzStatisticsPro.Common.Model;
+
+namespace WotBlitzStatisticsPro.Logic.Calculations
+{
+ public static class StatisticsHelper
+ {
+ public static void FillDifference(
+ this StatisticsDifference difference,
+ IStatistics firstItem,
+ IStatistics lastItem)
+ {
+ difference.LastBattleTime = firstItem.LastBattleTime.ToDateTime();
+ difference.Battles = new StatisticsDifferenceItem
+ {
+ CurrentValue = firstItem.Battles ?? 0,
+ Difference = firstItem.Battles - lastItem.Battles
+ };
+ difference.AvgTier = new StatisticsDifferenceItem
+ {
+ CurrentValue = firstItem.AvgTier,
+ Difference = firstItem.AvgTier - lastItem.AvgTier
+ };
+ difference.Wn7 = new StatisticsDifferenceItem
+ {
+ CurrentValue = firstItem.Wn7,
+ Difference = firstItem.Wn7 - lastItem.Wn7
+ };
+
+ decimal firstWinRate = lastItem.Battles.HasValue
+ ? 100 * (decimal)(lastItem.Wins ?? 0) /
+ lastItem.Battles.Value
+ : 0m;
+
+ decimal lastWinRate = firstItem.Battles.HasValue
+ ? 100 * (decimal)(firstItem.Wins ?? 0) /
+ firstItem.Battles.Value
+ : 0m;
+ difference.WinRate = new StatisticsDifferenceItem
+ {
+ CurrentValue = lastWinRate,
+ Difference = lastWinRate - firstWinRate
+ };
+
+
+ decimal firsAvgDmg = lastItem.Battles.HasValue
+ ? (decimal)(lastItem.DamageDealt ?? 0) /
+ lastItem.Battles.Value
+ : 0m;
+
+ decimal lastAvgDmg = firstItem.Battles.HasValue
+ ? (decimal)(firstItem.DamageDealt ?? 0) /
+ firstItem.Battles.Value
+ : 0m;
+ difference.AvgDamage = new StatisticsDifferenceItem
+ {
+ CurrentValue = lastAvgDmg,
+ Difference = lastAvgDmg - firsAvgDmg
+ };
+
+ decimal firsAvgXp = lastItem.Battles.HasValue
+ ? (decimal)(lastItem.Xp ?? 0) /
+ lastItem.Battles.Value
+ : 0m;
+
+ decimal lastAvgXp = firstItem.Battles.HasValue
+ ? (decimal)(firstItem.Xp ?? 0) /
+ firstItem.Battles.Value
+ : 0m;
+ difference.AvgXp = new StatisticsDifferenceItem
+ {
+ CurrentValue = lastAvgXp,
+ Difference = lastAvgXp - firsAvgXp
+ };
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/Mappers/ShortStatisticsProfile.cs b/WotBlitzStatisticsPro.Logic/Mappers/ShortStatisticsProfile.cs
new file mode 100644
index 0000000..d5a7e37
--- /dev/null
+++ b/WotBlitzStatisticsPro.Logic/Mappers/ShortStatisticsProfile.cs
@@ -0,0 +1,23 @@
+using AutoMapper;
+using WotBlitzStatisticsPro.Common.Model;
+using WotBlitzStatisticsPro.Logic.Calculations;
+
+namespace WotBlitzStatisticsPro.Logic.Mappers
+{
+ public class ShortStatisticsProfile: Profile
+ {
+ public ShortStatisticsProfile()
+ {
+ CreateMap()
+ .ForMember(d => d.LastBattleTime,
+ o => o.MapFrom(s => s.LastBattleTime.ToDateTime()))
+ .ForMember(d => d.AvgDamage,
+ o => o.MapFrom(s => s.Battles.HasValue && s.Battles > 0 ? ((decimal)s.DamageDealt / s.Battles) : 0m))
+ .ForMember(d => d.AvgXp,
+ o => o.MapFrom(s => s.Battles.HasValue && s.Battles > 0 ? ((decimal)s.Xp / s.Battles) : 0m))
+ .ForMember(d => d.WinRate,
+ o => o.MapFrom(s => s.Battles.HasValue && s.Battles > 0 ? (100 * (decimal)s.Wins / s.Battles) : 0m))
+ ;
+ }
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/WargamingAccounts.cs b/WotBlitzStatisticsPro.Logic/WargamingAccounts.cs
index 1b8a36a..f4bbc9d 100644
--- a/WotBlitzStatisticsPro.Logic/WargamingAccounts.cs
+++ b/WotBlitzStatisticsPro.Logic/WargamingAccounts.cs
@@ -62,20 +62,19 @@ namespace WotBlitzStatisticsPro.Logic
public async Task GetAccountInfoHistory(RealmType realm, long accountId, DateTime startDate, RequestLanguage requestLanguage)
{
- var contextData = new HistoryInformationPipelineContextData();
+ var contextData = new AccountHistoryInformationPipelineContextData(startDate);
var context = new OperationContext(new AccountRequest(accountId, realm, requestLanguage));
context.AddOrReplace(contextData);
var pipeline = new Pipeline(_operationFactory);
- // ToDo:
- // 1. First read account info from DB operation
pipeline.AddOperation()
-
- // 2. Read account history from DB at the startDate !Array SortedByDate! operation
- // 3. Fill the OverallAccountStatistics
- // PeriodAccountStatistics
- // PeriodDifference
- // StatisticsHistory
+ .AddOperation()
+ .AddOperation()
+ .AddOperation()
+ .AddOperation()
+ .AddOperation()
+ .AddOperation()
+ .AddOperation()
;
await pipeline.Build()
diff --git a/WotBlitzStatisticsPro.Logic/WotBlitzStatisticsLogicInstaller.cs b/WotBlitzStatisticsPro.Logic/WotBlitzStatisticsLogicInstaller.cs
index f81d029..1a085d7 100644
--- a/WotBlitzStatisticsPro.Logic/WotBlitzStatisticsLogicInstaller.cs
+++ b/WotBlitzStatisticsPro.Logic/WotBlitzStatisticsLogicInstaller.cs
@@ -66,6 +66,13 @@ namespace WotBlitzStatisticsPro.Logic
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
services.AddTransient(serviceProvider =>
new ServiceProviderOperationFactory(serviceProvider));