diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..1ff0c42
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,63 @@
+###############################################################################
+# Set default behavior to automatically normalize line endings.
+###############################################################################
+* text=auto
+
+###############################################################################
+# Set default behavior for command prompt diff.
+#
+# This is need for earlier builds of msysgit that does not have it on by
+# default for csharp files.
+# Note: This is only used by command line
+###############################################################################
+#*.cs diff=csharp
+
+###############################################################################
+# Set the merge driver for project and solution files
+#
+# Merging from the command prompt will add diff markers to the files if there
+# are conflicts (Merging from VS is not affected by the settings below, in VS
+# the diff markers are never inserted). Diff markers may cause the following
+# file extensions to fail to load in VS. An alternative would be to treat
+# these files as binary and thus will always conflict and require user
+# intervention with every merge. To do so, just uncomment the entries below
+###############################################################################
+#*.sln merge=binary
+#*.csproj merge=binary
+#*.vbproj merge=binary
+#*.vcxproj merge=binary
+#*.vcproj merge=binary
+#*.dbproj merge=binary
+#*.fsproj merge=binary
+#*.lsproj merge=binary
+#*.wixproj merge=binary
+#*.modelproj merge=binary
+#*.sqlproj merge=binary
+#*.wwaproj merge=binary
+
+###############################################################################
+# behavior for image files
+#
+# image files are treated as binary by default.
+###############################################################################
+#*.jpg binary
+#*.png binary
+#*.gif binary
+
+###############################################################################
+# diff behavior for common document formats
+#
+# Convert binary document formats to text before diffing them. This feature
+# is only available from the command line. Turn it on by uncommenting the
+# entries below.
+###############################################################################
+#*.doc diff=astextplain
+#*.DOC diff=astextplain
+#*.docx diff=astextplain
+#*.DOCX diff=astextplain
+#*.dot diff=astextplain
+#*.DOT diff=astextplain
+#*.pdf diff=astextplain
+#*.PDF diff=astextplain
+#*.rtf diff=astextplain
+#*.RTF diff=astextplain
diff --git a/WotBlitzStatisticsPro.Common/Model/AccountInfoHistoryResponse.cs b/WotBlitzStatisticsPro.Common/Model/AccountInfoHistoryResponse.cs
new file mode 100644
index 0000000..21cfcfa
--- /dev/null
+++ b/WotBlitzStatisticsPro.Common/Model/AccountInfoHistoryResponse.cs
@@ -0,0 +1,45 @@
+using System;
+
+namespace WotBlitzStatisticsPro.Common.Model
+{
+ ///
+ /// Information about player statistics history
+ ///
+ public class AccountInfoHistoryResponse
+ {
+ ///
+ /// Player account identifier
+ ///
+ public long AccountId { get; set; }
+
+ ///
+ /// Account creation date
+ ///
+ public DateTime CreatedAt { get; set; }
+
+ ///
+ /// Player's nick
+ ///
+ public string Nickname { get; set; }
+
+ ///
+ /// Overall statistics since account creation
+ ///
+ public ShortStatistics OverallAccountStatistics { get; set; }
+
+ ///
+ /// Statistics for period
+ ///
+ public ShortStatistics PeriodAccountStatistics { get; set; }
+
+ ///
+ /// Difference between start and end of the period
+ ///
+ public StatisticsDifference PeriodDifference { get; set; }
+
+ ///
+ /// The detailed history
+ ///
+ public StatisticsDifference[] StatisticsHistory { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Common/Model/ShortStatistics.cs b/WotBlitzStatisticsPro.Common/Model/ShortStatistics.cs
new file mode 100644
index 0000000..ee5ecf7
--- /dev/null
+++ b/WotBlitzStatisticsPro.Common/Model/ShortStatistics.cs
@@ -0,0 +1,46 @@
+using System;
+
+namespace WotBlitzStatisticsPro.Common.Model
+{
+ ///
+ /// Short statistics info
+ ///
+ public class ShortStatistics
+ {
+ ///
+ /// Last battle time
+ ///
+ public DateTime LastBattleTime { get; set; }
+
+ ///
+ /// Battles count
+ ///
+ public long Battles { get; set; }
+
+ ///
+ /// Average tier
+ ///
+ public double AvgTier { get; set; }
+
+ ///
+ /// Wn7 coefficient
+ ///
+ public double Wn7 { get; set; }
+
+ ///
+ /// Player's win rate
+ ///
+ public decimal WinRate { get; set; }
+
+ ///
+ /// Player's average damage
+ ///
+ public decimal AvgDamage { get; set; }
+
+ ///
+ /// Player's average XP
+ ///
+ public decimal AvgXp { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Common/Model/StatisticsDifference.cs b/WotBlitzStatisticsPro.Common/Model/StatisticsDifference.cs
new file mode 100644
index 0000000..c495e98
--- /dev/null
+++ b/WotBlitzStatisticsPro.Common/Model/StatisticsDifference.cs
@@ -0,0 +1,46 @@
+using System;
+
+namespace WotBlitzStatisticsPro.Common.Model
+{
+ ///
+ /// The difference between current statistics state and previous
+ ///
+ public class StatisticsDifference
+ {
+ ///
+ /// Last battle time
+ ///
+ public DateTime LastBattleTime { get; set; }
+
+ ///
+ /// Difference in Battles count
+ ///
+ public StatisticsDifferenceItem Battles { get; set; }
+
+ ///
+ /// Difference in Average tier
+ ///
+ public StatisticsDifferenceItem AvgTier { get; set; }
+
+ ///
+ /// Difference in Wn7 coefficient
+ ///
+ public StatisticsDifferenceItem Wn7 { get; set; }
+
+ ///
+ /// Difference in Player's win rate
+ ///
+ public StatisticsDifferenceItem WinRate { get; set; }
+
+ ///
+ /// Difference in Player's average damage
+ ///
+ public StatisticsDifferenceItem AvgDamage { get; set; }
+
+ ///
+ /// Difference in Player's average XP
+ ///
+ public StatisticsDifferenceItem AvgXp { get; set; }
+
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Common/Model/StatisticsDifferenceItem.cs b/WotBlitzStatisticsPro.Common/Model/StatisticsDifferenceItem.cs
new file mode 100644
index 0000000..18172d5
--- /dev/null
+++ b/WotBlitzStatisticsPro.Common/Model/StatisticsDifferenceItem.cs
@@ -0,0 +1,18 @@
+namespace WotBlitzStatisticsPro.Common.Model
+{
+ ///
+ /// Represents the difference of one statistics parameter
+ ///
+ public class StatisticsDifferenceItem where T: struct
+ {
+ ///
+ /// The current value of statistics item
+ ///
+ public T CurrentValue { get; set; }
+
+ ///
+ /// The difference between current and previous value
+ ///
+ public T? Difference { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.DataAccess/IWargamingAccountDataAccessor.cs b/WotBlitzStatisticsPro.DataAccess/IWargamingAccountDataAccessor.cs
index b3ea862..31d1f36 100644
--- a/WotBlitzStatisticsPro.DataAccess/IWargamingAccountDataAccessor.cs
+++ b/WotBlitzStatisticsPro.DataAccess/IWargamingAccountDataAccessor.cs
@@ -1,4 +1,5 @@
-using System.Threading.Tasks;
+using System.Collections.Generic;
+using System.Threading.Tasks;
using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
namespace WotBlitzStatisticsPro.DataAccess
@@ -16,5 +17,9 @@ namespace WotBlitzStatisticsPro.DataAccess
Task AddOrUpdateTankInfo(TankInfo tankInfo);
Task AddTankInfoHistory(TankInfoHistory tankInfoHistory);
+
+ Task> GetAccountHistory(long accountId, int lastBattleSince);
+
+ Task> GetTankHistory(long accountId, long tankId, int lastBattleSince);
}
}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.DataAccess/WargamingAccountDataAccessor.cs b/WotBlitzStatisticsPro.DataAccess/WargamingAccountDataAccessor.cs
index 6ab9eb8..446443d 100644
--- a/WotBlitzStatisticsPro.DataAccess/WargamingAccountDataAccessor.cs
+++ b/WotBlitzStatisticsPro.DataAccess/WargamingAccountDataAccessor.cs
@@ -1,4 +1,5 @@
-using System.Threading.Tasks;
+using System.Collections.Generic;
+using System.Threading.Tasks;
using MongoDB.Driver;
using WotBlitzStatisticsPro.Common;
using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
@@ -109,5 +110,15 @@ namespace WotBlitzStatisticsPro.DataAccess
return _database.GetCollection(TankInfoHistoryCollectionName)
.InsertOneAsync(tankInfoHistory);
}
+
+ public Task> GetAccountHistory(long accountId, int lastBattleSince)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public Task> GetTankHistory(long accountId, long tankId, int lastBattleSince)
+ {
+ throw new System.NotImplementedException();
+ }
}
}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.GraphQl/Query/WotBlitzStatisticsQuery.cs b/WotBlitzStatisticsPro.GraphQl/Query/WotBlitzStatisticsQuery.cs
index b237b6c..9679e42 100644
--- a/WotBlitzStatisticsPro.GraphQl/Query/WotBlitzStatisticsQuery.cs
+++ b/WotBlitzStatisticsPro.GraphQl/Query/WotBlitzStatisticsQuery.cs
@@ -1,4 +1,5 @@
-using System.Threading.Tasks;
+using System;
+using System.Threading.Tasks;
using WotBlitzStatisticsPro.Common.Model;
using WotBlitzStatisticsPro.Logic;
@@ -68,5 +69,23 @@ namespace WotBlitzStatisticsPro.GraphQl.Query
{
return _wargamingAccounts.GatherAccountInformation(realmType ?? RealmType.Ru, accountId, requestLanguage ?? RequestLanguage.En);
}
+
+ ///
+ /// Account statistics history for period since "startDate"
+ ///
+ /// AccountId
+ /// Date from history started
+ /// Account region
+ /// Request language
+ ///
+ public Task AccountInfoHistory(
+ long accountId,
+ DateTime startDate,
+ RealmType? realmType,
+ RequestLanguage? requestLanguage)
+ {
+ return _wargamingAccounts.GetAccountInfoHistory(realmType ?? RealmType.Ru, accountId, startDate,
+ requestLanguage ?? RequestLanguage.En);
+ }
}
}
diff --git a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/AccountInformationPipelineContext.cs b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/AccountInformationPipelineContext.cs
index ed599bf..dedb9d0 100644
--- a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/AccountInformationPipelineContext.cs
+++ b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/AccountInformationPipelineContext.cs
@@ -4,7 +4,7 @@ using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
{
- public class AccountInformationPipelineContext
+ public class AccountInformationPipelineContext: IDatabasePipelineContext
{
public AccountInformationPipelineContext(
long accountId,
diff --git a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/HistoryInformationPipelineContext.cs b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/HistoryInformationPipelineContext.cs
new file mode 100644
index 0000000..1864bb8
--- /dev/null
+++ b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/HistoryInformationPipelineContext.cs
@@ -0,0 +1,28 @@
+using WotBlitzStatisticsPro.Common.Model;
+using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
+
+namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
+{
+ public class HistoryInformationPipelineContext: IDatabasePipelineContext
+ {
+ public HistoryInformationPipelineContext(
+ long accountId,
+ RealmType realmType,
+ RequestLanguage requestLanguage)
+ {
+ AccountId = accountId;
+ RealmType = realmType;
+ RequestLanguage = requestLanguage;
+ }
+
+
+ public long AccountId { get; }
+ public RealmType RealmType { get; }
+ public RequestLanguage RequestLanguage { get; }
+
+ public AccountInfo DbAccountInfo { get; set; }
+
+
+ public AccountInfoHistoryResponse Response { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/IAccountPipelineContext.cs b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/IAccountPipelineContext.cs
new file mode 100644
index 0000000..2c187a1
--- /dev/null
+++ b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/IAccountPipelineContext.cs
@@ -0,0 +1,11 @@
+using WotBlitzStatisticsPro.Common.Model;
+
+namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
+{
+ public interface IAccountPipelineContext
+ {
+ long AccountId { get; }
+ RealmType RealmType { get; }
+ RequestLanguage RequestLanguage { get; }
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/IDatabasePipelineContext.cs b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/IDatabasePipelineContext.cs
new file mode 100644
index 0000000..9454ee0
--- /dev/null
+++ b/WotBlitzStatisticsPro.Logic/AccountInformationPipeline/IDatabasePipelineContext.cs
@@ -0,0 +1,9 @@
+using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
+
+namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
+{
+ public interface IDatabasePipelineContext: IAccountPipelineContext
+ {
+ AccountInfo DbAccountInfo { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/IWargamingAccounts.cs b/WotBlitzStatisticsPro.Logic/IWargamingAccounts.cs
index e28dc55..34134cf 100644
--- a/WotBlitzStatisticsPro.Logic/IWargamingAccounts.cs
+++ b/WotBlitzStatisticsPro.Logic/IWargamingAccounts.cs
@@ -1,4 +1,5 @@
-using System.Threading.Tasks;
+using System;
+using System.Threading.Tasks;
using WotBlitzStatisticsPro.Common.Model;
namespace WotBlitzStatisticsPro.Logic
@@ -8,5 +9,8 @@ namespace WotBlitzStatisticsPro.Logic
Task GatherAccountInformation(RealmType realm, long accountId, RequestLanguage requestLanguage);
Task GatherAndSaveAccountInformation(RealmType realm, long accountId, RequestLanguage requestLanguage);
+
+ Task GetAccountInfoHistory(RealmType realm, long accountId, DateTime startDate,
+ RequestLanguage requestLanguage);
}
}
\ No newline at end of file
diff --git a/WotBlitzStatisticsPro.Logic/WargamingAccounts.cs b/WotBlitzStatisticsPro.Logic/WargamingAccounts.cs
index c51bed5..5de30a5 100644
--- a/WotBlitzStatisticsPro.Logic/WargamingAccounts.cs
+++ b/WotBlitzStatisticsPro.Logic/WargamingAccounts.cs
@@ -1,4 +1,5 @@
-using System.Threading.Tasks;
+using System;
+using System.Threading.Tasks;
using WotBlitzStatisticsPro.Common.Model;
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline;
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations;
@@ -53,5 +54,27 @@ namespace WotBlitzStatisticsPro.Logic
return context.Response;
}
+
+ public async Task GetAccountInfoHistory(RealmType realm, long accountId, DateTime startDate, RequestLanguage requestLanguage)
+ {
+ var context = new HistoryInformationPipelineContext(accountId, realm, requestLanguage);
+ var pipeline = new Pipeline(_operationFactory);
+
+ //pipeline.AddOperation()
+
+ // ToDo:
+ // 1. First read account info from DB operation
+ // 2. Read account history from DB at the startDate !Array SortedByDate! operation
+ // 3. Fill the OverallAccountStatistics
+ // PeriodAccountStatistics
+ // PeriodDifference
+ // StatisticsHistory
+
+ await pipeline.Build()
+ .Invoke(context, null)
+ .ConfigureAwait(false);
+
+ return context.Response;
+ }
}
}
\ No newline at end of file