Preparing for the History query

This commit is contained in:
Mikhail Shabanov committed 2020-11-17 11:01:35 +01:00
1 parent ddbf42e7bb
commit ed52a65788
14 files changed
+334 -6

No files matched your search

@@ -4,7 +4,7 @@ using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
{
public class AccountInformationPipelineContext
public class AccountInformationPipelineContext: IDatabasePipelineContext
{
public AccountInformationPipelineContext(
long accountId,
@@ -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; }
}
}
@@ -0,0 +1,11 @@
using WotBlitzStatisticsPro.Common.Model;
namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
{
public interface IAccountPipelineContext
{
long AccountId { get; }
RealmType RealmType { get; }
RequestLanguage RequestLanguage { get; }
}
}
@@ -0,0 +1,9 @@
using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
{
public interface IDatabasePipelineContext: IAccountPipelineContext
{
AccountInfo DbAccountInfo { get; set; }
}
}
@@ -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<AccountInfoResponse> GatherAccountInformation(RealmType realm, long accountId, RequestLanguage requestLanguage);
Task<AccountInfoResponse> GatherAndSaveAccountInformation(RealmType realm, long accountId, RequestLanguage requestLanguage);
Task<AccountInfoHistoryResponse> GetAccountInfoHistory(RealmType realm, long accountId, DateTime startDate,
RequestLanguage requestLanguage);
}
}
@@ -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<AccountInfoHistoryResponse> GetAccountInfoHistory(RealmType realm, long accountId, DateTime startDate, RequestLanguage requestLanguage)
{
var context = new HistoryInformationPipelineContext(accountId, realm, requestLanguage);
var pipeline = new Pipeline<HistoryInformationPipelineContext>(_operationFactory);
//pipeline.AddOperation<ReadAccountInfoFromDbOperation>()
// 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;
}
}
}