mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-23 19:30:06 +02:00
Tank info history query
This commit is contained in:
1 parent
9b9f2b141e
commit
eef4e9255b
14 files changed
+352
-32
No files matched your search
@@ -0,0 +1,92 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace WotBlitzStatisticsPro.Common.Model
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Information about tank statistics history
|
||||||
|
/// </summary>
|
||||||
|
public class TankInfoHistoryResponse
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
/// Player account identifier
|
||||||
|
///</summary>
|
||||||
|
public long AccountId { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// Tank identifier
|
||||||
|
///</summary>
|
||||||
|
public long TankId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Total time in battle until tank killed
|
||||||
|
/// </summary>
|
||||||
|
public int BattleLifeTimeInSeconds { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// Last battle
|
||||||
|
///</summary>
|
||||||
|
public DateTime LastBattleTime { get; set; } = new DateTime(1970, 1, 1);
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// Mark of Mastery
|
||||||
|
///</summary>
|
||||||
|
public MarkOfMastery MarkOfMastery { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tank name
|
||||||
|
/// </summary>
|
||||||
|
public string? Name { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// Is vehicle premium
|
||||||
|
///</summary>
|
||||||
|
public bool IsPremium { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// Vehicle type id
|
||||||
|
///</summary>
|
||||||
|
public string? Type { get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// Vehicle nationId
|
||||||
|
///</summary>
|
||||||
|
public string? Nation{ get; set; }
|
||||||
|
|
||||||
|
///<summary>
|
||||||
|
/// Vehicle tier
|
||||||
|
///</summary>
|
||||||
|
public int Tier { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Vehicle preview image
|
||||||
|
/// </summary>
|
||||||
|
public string? PreviewImage { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Vehicle normal image
|
||||||
|
/// </summary>
|
||||||
|
public string? NormalImage { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overall statistics since tank was bought
|
||||||
|
/// </summary>
|
||||||
|
public ShortStatistics? OverallTankStatistics { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Statistics for period
|
||||||
|
/// </summary>
|
||||||
|
public ShortStatistics? TankPeriodStatistics { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Difference between start and end of the period
|
||||||
|
/// </summary>
|
||||||
|
public StatisticsDifference? PeriodDifference { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The detailed history
|
||||||
|
/// </summary>
|
||||||
|
public StatisticsDifference[]? StatisticsHistory { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
using MongoDB.Bson.Serialization.Attributes;
|
using MongoDB.Bson.Serialization.Attributes;
|
||||||
|
using WotBlitzStatisticsPro.Common.Model;
|
||||||
|
|
||||||
namespace WotBlitzStatisticsPro.DataAccess.Model.Accounts
|
namespace WotBlitzStatisticsPro.DataAccess.Model.Accounts
|
||||||
{
|
{
|
||||||
public class TankInfoHistory
|
public class TankInfoHistory: IStatistics
|
||||||
{
|
{
|
||||||
|
|
||||||
public TankInfoHistory()
|
public TankInfoHistory()
|
||||||
{
|
{
|
||||||
@@ -41,91 +42,100 @@ namespace WotBlitzStatisticsPro.DataAccess.Model.Accounts
|
|||||||
///<summary>
|
///<summary>
|
||||||
/// Battles count
|
/// Battles count
|
||||||
///</summary>
|
///</summary>
|
||||||
public long Battles { get; set; }
|
public long? Battles { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Base capture points
|
/// Base capture points
|
||||||
///</summary>
|
///</summary>
|
||||||
public long CapturePoints { get; set; }
|
public long? CapturePoints { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Damage dealt
|
/// Damage dealt
|
||||||
///</summary>
|
///</summary>
|
||||||
public long DamageDealt { get; set; }
|
public long? DamageDealt { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Damage received
|
/// Damage received
|
||||||
///</summary>
|
///</summary>
|
||||||
public long DamageReceived { get; set; }
|
public long? DamageReceived { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Base dropped capture points
|
/// Base dropped capture points
|
||||||
///</summary>
|
///</summary>
|
||||||
public long DroppedCapturePoints { get; set; }
|
public long? DroppedCapturePoints { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Frags count
|
/// Frags count
|
||||||
///</summary>
|
///</summary>
|
||||||
public long Frags { get; set; }
|
public long? Frags { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Frags count after 8 tier
|
/// Frags count after 8 tier
|
||||||
///</summary>
|
///</summary>
|
||||||
public long Frags8P { get; set; }
|
public long? Frags8P { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Hits count
|
/// Hits count
|
||||||
///</summary>
|
///</summary>
|
||||||
public long Hits { get; set; }
|
public long? Hits { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Losses count
|
/// Losses count
|
||||||
///</summary>
|
///</summary>
|
||||||
public long Losses { get; set; }
|
public long? Losses { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Max frags per battle
|
/// Max frags per battle
|
||||||
///</summary>
|
///</summary>
|
||||||
public long MaxFrags { get; set; }
|
public long? MaxFrags { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Max XP per battle
|
/// Max XP per battle
|
||||||
///</summary>
|
///</summary>
|
||||||
public long MaxXp { get; set; }
|
public long? MaxXp { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Shots count
|
/// Shots count
|
||||||
///</summary>
|
///</summary>
|
||||||
public long Shots { get; set; }
|
public long? Shots { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Spotted vehicles count
|
/// Spotted vehicles count
|
||||||
///</summary>
|
///</summary>
|
||||||
public long Spotted { get; set; }
|
public long? Spotted { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Amount of survived battles
|
/// Amount of survived battles
|
||||||
///</summary>
|
///</summary>
|
||||||
public long SurvivedBattles { get; set; }
|
public long? SurvivedBattles { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Amount of survived and wined battles
|
/// Amount of survived and wined battles
|
||||||
///</summary>
|
///</summary>
|
||||||
public long WinAndSurvived { get; set; }
|
public long? WinAndSurvived { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Wins count
|
/// Wins count
|
||||||
///</summary>
|
///</summary>
|
||||||
public long Wins { get; set; }
|
public long? Wins { get; set; }
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
/// Total experience
|
/// Total experience
|
||||||
///</summary>
|
///</summary>
|
||||||
public long Xp { get; set; }
|
public long? Xp { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wn7 coefficient
|
/// Wn7 coefficient
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Wn7 { get; set; }
|
public double Wn7 { get; set; }
|
||||||
|
|
||||||
|
#region redudant fields
|
||||||
|
|
||||||
|
public long? MaxFragsTankId { get; set; }
|
||||||
|
public long? MaxXpTankId { get; set; }
|
||||||
|
public double AvgTier { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ namespace WotBlitzStatisticsPro.DataAccess
|
|||||||
var history = await _database.GetCollection<TankInfoHistory>(TankInfoHistoryCollectionName)
|
var history = await _database.GetCollection<TankInfoHistory>(TankInfoHistoryCollectionName)
|
||||||
.FindAsync(
|
.FindAsync(
|
||||||
Builders<TankInfoHistory>.Filter.Where(t =>
|
Builders<TankInfoHistory>.Filter.Where(t =>
|
||||||
t.TankInfoHistoryId.AccountId == accountId && t.TankId == tankId && t.TankInfoHistoryId.LastBattleTime >= lastBattleSince),
|
t.TankInfoHistoryId.AccountId == accountId && t.TankInfoHistoryId.TankId == tankId && t.TankInfoHistoryId.LastBattleTime >= lastBattleSince),
|
||||||
new FindOptions<TankInfoHistory>
|
new FindOptions<TankInfoHistory>
|
||||||
{Sort = Builders<TankInfoHistory>.Sort.Descending(h => h.TankInfoHistoryId.LastBattleTime)});
|
{Sort = Builders<TankInfoHistory>.Sort.Descending(h => h.TankInfoHistoryId.LastBattleTime)});
|
||||||
return history.ToList();
|
return history.ToList();
|
||||||
|
|||||||
@@ -20,11 +20,6 @@ namespace WotBlitzStatisticsPro.GraphQl.Query
|
|||||||
_wargamingAccounts = wargamingAccounts;
|
_wargamingAccounts = wargamingAccounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
//public Task<AccountInfo> GetPlayerInfo(long accountId)
|
|
||||||
//{
|
|
||||||
// return _wargamingSearcher.GetPlayerAccountInfo(accountId);
|
|
||||||
//}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds Wargaming accounts by nick
|
/// Finds Wargaming accounts by nick
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -87,5 +82,25 @@ namespace WotBlitzStatisticsPro.GraphQl.Query
|
|||||||
return _wargamingAccounts.GetAccountInfoHistory(realmType ?? RealmType.Ru, accountId, startDate,
|
return _wargamingAccounts.GetAccountInfoHistory(realmType ?? RealmType.Ru, accountId, startDate,
|
||||||
requestLanguage ?? RequestLanguage.En);
|
requestLanguage ?? RequestLanguage.En);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tank statistics history for period since "startDate"
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="accountId">AccountId</param>
|
||||||
|
/// <param name="tankId">TankId</param>
|
||||||
|
/// <param name="startDate">Date from history started</param>
|
||||||
|
/// <param name="realmType">Account region</param>
|
||||||
|
/// <param name="requestLanguage">Request language</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<TankInfoHistoryResponse> TankInfoHistory(
|
||||||
|
long accountId,
|
||||||
|
long tankId,
|
||||||
|
DateTime startDate,
|
||||||
|
RealmType? realmType,
|
||||||
|
RequestLanguage? requestLanguage)
|
||||||
|
{
|
||||||
|
return _wargamingAccounts.GetTankInfoHistory(realmType ?? RealmType.Ru, accountId, tankId, startDate,
|
||||||
|
requestLanguage ?? RequestLanguage.En);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
|
||||||
|
|
||||||
|
namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
|
||||||
|
{
|
||||||
|
public interface IDatabaseTankPipelineContextData
|
||||||
|
{
|
||||||
|
long TankId { get; }
|
||||||
|
|
||||||
|
TankInfo? DbTankInfo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
+61
@@ -0,0 +1,61 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WotBlitzStatisticsPro.Common.Model;
|
||||||
|
using WotBlitzStatisticsPro.DataAccess;
|
||||||
|
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
|
||||||
|
using WotBlitzStatisticsPro.Logic.Calculations;
|
||||||
|
using WotBlitzStatisticsPro.Logic.Pipeline;
|
||||||
|
|
||||||
|
namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||||
|
{
|
||||||
|
public class FillTankHistoryResponseOperation : IOperation<IOperationContext>
|
||||||
|
{
|
||||||
|
private readonly IDictionariesDataAccessor _wargamingDictionaries;
|
||||||
|
|
||||||
|
public FillTankHistoryResponseOperation(IDictionariesDataAccessor wargamingDictionaries)
|
||||||
|
{
|
||||||
|
_wargamingDictionaries = wargamingDictionaries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||||
|
{
|
||||||
|
var contextData = context.Get<TankHistoryInformationContextData>();
|
||||||
|
|
||||||
|
if (contextData?.DbTankInfo == null)
|
||||||
|
{
|
||||||
|
if (next != null) await next.Invoke(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var nations = await _wargamingDictionaries.GetNations(context.Request.RequestLanguage);
|
||||||
|
var tankTypes = await _wargamingDictionaries.GetTankTypes(context.Request.RequestLanguage);
|
||||||
|
|
||||||
|
var vehicleInfos = await _wargamingDictionaries.GetVehicles(new[] {contextData.TankId});
|
||||||
|
var vehicleInfo = vehicleInfos[contextData.TankId];
|
||||||
|
|
||||||
|
contextData.Response = new TankInfoHistoryResponse
|
||||||
|
{
|
||||||
|
TankId = contextData.TankId,
|
||||||
|
LastBattleTime = contextData.DbTankInfo.LastBattleTime.ToDateTime(),
|
||||||
|
BattleLifeTimeInSeconds = contextData.DbTankInfo.BattleLifeTimeInSeconds,
|
||||||
|
MarkOfMastery = contextData.DbTankInfo.MarkOfMastery,
|
||||||
|
Name = vehicleInfo.Name.FirstOrDefault(n => n.Language == context.Request.RequestLanguage)?.Value,
|
||||||
|
IsPremium = vehicleInfo.IsPremium,
|
||||||
|
Tier = vehicleInfo.Tier,
|
||||||
|
NormalImage = vehicleInfo.NormalImage,
|
||||||
|
PreviewImage = vehicleInfo.PreviewImage,
|
||||||
|
Nation = nations[vehicleInfo.NationId],
|
||||||
|
Type = tankTypes[vehicleInfo.TypeId],
|
||||||
|
|
||||||
|
AccountId = context.Request.AccountId,
|
||||||
|
PeriodDifference = contextData.PeriodDifference,
|
||||||
|
StatisticsHistory = contextData.StatisticsHistory,
|
||||||
|
TankPeriodStatistics = contextData.PeriodAccountStatistics,
|
||||||
|
OverallTankStatistics = contextData.OverallStatistics
|
||||||
|
};
|
||||||
|
|
||||||
|
if (next != null) await next.Invoke(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
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 ReadTankHistoryFromDbOperation : IOperation<IOperationContext>
|
||||||
|
{
|
||||||
|
private readonly IWargamingAccountDataAccessor _accountDataAccessor;
|
||||||
|
|
||||||
|
public ReadTankHistoryFromDbOperation(IWargamingAccountDataAccessor accountDataAccessor)
|
||||||
|
{
|
||||||
|
_accountDataAccessor = accountDataAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||||
|
{
|
||||||
|
var contextData = context.Get<TankHistoryInformationContextData>();
|
||||||
|
|
||||||
|
contextData.History = (await _accountDataAccessor.GetTankHistory(context.Request.AccountId, contextData.TankId, contextData.LastBattleSince.ToUnixTimestamp())).ToArray();
|
||||||
|
if (next != null) await next.Invoke(context);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using WotBlitzStatisticsPro.DataAccess;
|
||||||
|
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.OperationContext;
|
||||||
|
using WotBlitzStatisticsPro.Logic.Pipeline;
|
||||||
|
|
||||||
|
namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||||
|
{
|
||||||
|
public class ReadTankInfoFromDbOperation : IOperation<IOperationContext>
|
||||||
|
{
|
||||||
|
private readonly IWargamingAccountDataAccessor _accountDataAccessor;
|
||||||
|
|
||||||
|
public ReadTankInfoFromDbOperation(IWargamingAccountDataAccessor accountDataAccessor)
|
||||||
|
{
|
||||||
|
_accountDataAccessor = accountDataAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Invoke(IOperationContext context, Func<IOperationContext, Task>? next)
|
||||||
|
{
|
||||||
|
var contextData = context.Get<IDatabaseTankPipelineContextData>();
|
||||||
|
|
||||||
|
contextData.DbTankInfo = await _accountDataAccessor.ReadTankInfo(context.Request.AccountId, contextData.TankId);
|
||||||
|
if (next != null) await next.Invoke(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using WotBlitzStatisticsPro.Common.Model;
|
||||||
|
using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
|
||||||
|
|
||||||
|
namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
|
||||||
|
{
|
||||||
|
public class TankHistoryInformationContextData: IDatabaseTankPipelineContextData, IStatisticsPipelineData
|
||||||
|
{
|
||||||
|
public TankHistoryInformationContextData(DateTime lastBattleSince, long tankId)
|
||||||
|
{
|
||||||
|
LastBattleSince = lastBattleSince;
|
||||||
|
TankId = tankId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTime LastBattleSince { get; }
|
||||||
|
|
||||||
|
public long TankId { get; }
|
||||||
|
|
||||||
|
public TankInfo? DbTankInfo { 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 TankInfoHistoryResponse? Response { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@ namespace WotBlitzStatisticsPro.Logic.Calculations
|
|||||||
{
|
{
|
||||||
if (tankTires.ContainsKey(tank.TankId) && tank.Battles > 0)
|
if (tankTires.ContainsKey(tank.TankId) && tank.Battles > 0)
|
||||||
{
|
{
|
||||||
x += tankTires[tank.TankId] * tank.Battles;
|
x += tankTires[tank.TankId] * tank.Battles.DoubleValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (account.Battles > 0)
|
if (account.Battles > 0)
|
||||||
|
|||||||
@@ -26,13 +26,18 @@ namespace WotBlitzStatisticsPro.Logic.Calculations
|
|||||||
|
|
||||||
public static void CalculateWn7(this TankInfoHistory tank, double tier)
|
public static void CalculateWn7(this TankInfoHistory tank, double tier)
|
||||||
{
|
{
|
||||||
double avdFrags = (double) tank.Frags / tank.Battles;
|
if (!tank.Battles.HasValue)
|
||||||
double avgDamage = (double)tank.DamageDealt / tank.Battles;
|
{
|
||||||
double avgSpot = (double)tank.Spotted / tank.Battles;
|
return;
|
||||||
double avgDef = (double)tank.DroppedCapturePoints / tank.Battles;
|
}
|
||||||
double winRate = (100d * (double) tank.Wins / tank.Battles); // - 48;
|
|
||||||
|
|
||||||
tank.Wn7 = CalculateWn7(tank.Battles, tier, avdFrags, avgDamage, avgSpot, avgDef, winRate);
|
double avdFrags = (double) tank.Frags.DoubleValue() / tank.Battles.DoubleValue();
|
||||||
|
double avgDamage = (double)tank.DamageDealt.DoubleValue() / tank.Battles.DoubleValue();
|
||||||
|
double avgSpot = (double)tank.Spotted.DoubleValue() / tank.Battles.DoubleValue();
|
||||||
|
double avgDef = (double)tank.DroppedCapturePoints.DoubleValue() / tank.Battles.DoubleValue();
|
||||||
|
double winRate = (100d * (double) tank.Wins.DoubleValue() / tank.Battles.DoubleValue()); // - 48;
|
||||||
|
|
||||||
|
tank.Wn7 = CalculateWn7(tank.Battles.Value, tier, avdFrags, avgDamage, avgSpot, avgDef, winRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CalculateWn7(this AccountInfoHistory account)
|
public static void CalculateWn7(this AccountInfoHistory account)
|
||||||
|
|||||||
@@ -12,5 +12,8 @@ namespace WotBlitzStatisticsPro.Logic
|
|||||||
|
|
||||||
Task<AccountInfoHistoryResponse> GetAccountInfoHistory(RealmType realm, long accountId, DateTime startDate,
|
Task<AccountInfoHistoryResponse> GetAccountInfoHistory(RealmType realm, long accountId, DateTime startDate,
|
||||||
RequestLanguage requestLanguage);
|
RequestLanguage requestLanguage);
|
||||||
|
|
||||||
|
Task<TankInfoHistoryResponse> GetTankInfoHistory(RealmType realm, long accountId, long tankId, DateTime startDate,
|
||||||
|
RequestLanguage requestLanguage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,5 +126,41 @@ namespace WotBlitzStatisticsPro.Logic
|
|||||||
}
|
}
|
||||||
return contextData?.Response ?? new AccountInfoHistoryResponse();
|
return contextData?.Response ?? new AccountInfoHistoryResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<TankInfoHistoryResponse> GetTankInfoHistory(RealmType realm, long accountId, long tankId, DateTime startDate,
|
||||||
|
RequestLanguage requestLanguage)
|
||||||
|
{
|
||||||
|
var contextData = new TankHistoryInformationContextData(startDate, tankId);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var context = new OperationContext(new AccountRequest(accountId, realm, requestLanguage));
|
||||||
|
context.AddOrReplace(contextData);
|
||||||
|
var pipeline = new Pipeline<IOperationContext>(_operationFactory);
|
||||||
|
|
||||||
|
pipeline.AddOperation<ReadTankInfoFromDbOperation>()
|
||||||
|
.AddOperation<ReadTankHistoryFromDbOperation>()
|
||||||
|
.AddOperation<CheckIfHistoryIsEmptyOperation>()
|
||||||
|
.AddOperation<FillOverallStatisticsOperation>()
|
||||||
|
.AddOperation<FillPeriodStatisticsOperation>()
|
||||||
|
.AddOperation<FillPeriodDifferenceOperation>()
|
||||||
|
.AddOperation<FillStatisticsDifferenceOperation>()
|
||||||
|
.AddOperation<FillTankHistoryResponseOperation>()
|
||||||
|
;
|
||||||
|
|
||||||
|
var firstOperation = pipeline.Build();
|
||||||
|
if (firstOperation != null)
|
||||||
|
{
|
||||||
|
await firstOperation
|
||||||
|
.Invoke(context, null)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.LogError(e, "GetAccountInfoHistory error");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
return contextData?.Response ?? new TankInfoHistoryResponse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,6 +70,9 @@ namespace WotBlitzStatisticsPro.Logic
|
|||||||
services.AddTransient<FillPeriodDifferenceOperation>();
|
services.AddTransient<FillPeriodDifferenceOperation>();
|
||||||
services.AddTransient<FillStatisticsDifferenceOperation>();
|
services.AddTransient<FillStatisticsDifferenceOperation>();
|
||||||
services.AddTransient<FillAccountInfoHistoryResponse>();
|
services.AddTransient<FillAccountInfoHistoryResponse>();
|
||||||
|
services.AddTransient<ReadTankInfoFromDbOperation>();
|
||||||
|
services.AddTransient<ReadTankHistoryFromDbOperation>();
|
||||||
|
services.AddTransient<FillTankHistoryResponseOperation>();
|
||||||
|
|
||||||
services.AddTransient<IOperationFactory>(serviceProvider =>
|
services.AddTransient<IOperationFactory>(serviceProvider =>
|
||||||
new ServiceProviderOperationFactory(serviceProvider));
|
new ServiceProviderOperationFactory(serviceProvider));
|
||||||
|
|||||||
Reference in new issue
Block a user