mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-21 02:17:20 +02:00
GraphQl dataStructure refactored
This commit is contained in:
1 parent
95443d2996
commit
6c2104f6d7
8 files changed
+35
-154
No files matched your search
@@ -0,0 +1,6 @@
|
||||
namespace WotBlitzStatistics.GraphQl.ObjectTypes
|
||||
{
|
||||
public class PlayerAcchievementsInfoObjectType
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
using HotChocolate.Types;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||
|
||||
namespace WotBlitzStatistics.GraphQl.ObjectTypes
|
||||
{
|
||||
public class PlayerAccountInfoObjectType: ObjectType<PlayerAccountInfo>
|
||||
public class PlayerAccountInfoObjectType: ObjectType<AccountInfo>
|
||||
{
|
||||
protected override void Configure(IObjectTypeDescriptor<PlayerAccountInfo> descriptor)
|
||||
protected override void Configure(IObjectTypeDescriptor<AccountInfo> descriptor)
|
||||
{
|
||||
base.Configure(descriptor);
|
||||
descriptor.Field(a => a.Private).Ignore();
|
||||
descriptor.Field("Tanks").Type<NonNullType<ListType<StringType>>>()
|
||||
.Resolver(c => new List<string> { "Fuck yeah" });
|
||||
// Add resolver for Clan, Tanks, Achievements
|
||||
// https://hotchocolate.io/docs/schema-object-type
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace WotBlitzStatistics.GraphQl.ObjectTypes
|
||||
{
|
||||
public class PlayerClanInfoObjectType
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace WotBlitzStatistics.GraphQl.ObjectTypes
|
||||
{
|
||||
public class PlayerTankInfoObjectType
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Threading.Tasks;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.WgApiClient;
|
||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||
|
||||
namespace WotBlitzStatistics.GraphQl.Query
|
||||
{
|
||||
@@ -14,142 +14,9 @@ namespace WotBlitzStatistics.GraphQl.Query
|
||||
_wargamingApiClient = wargamingApiClient;
|
||||
}
|
||||
|
||||
public async Task<PlayerAccountInfo> GetPlayerInfo(long accountId)
|
||||
public Task<AccountInfo> GetPlayerInfo(long accountId)
|
||||
{
|
||||
var account = await _wargamingApiClient.GetPlayerAccountInfo(accountId);
|
||||
// ToDo: think abount mappers or resolvers
|
||||
var accountStub = JsonConvert.DeserializeObject<PlayerAccountInfo>(AccountJson);
|
||||
accountStub.AccountId = accountId;
|
||||
return accountStub;
|
||||
return _wargamingApiClient.GetPlayerAccountInfo(accountId);
|
||||
}
|
||||
|
||||
|
||||
private const string AccountJson =
|
||||
@"
|
||||
{
|
||||
""AccountId"": 90277267,
|
||||
""NickName"": ""Mboga [XXX_L]"",
|
||||
""AccountCreatedAt"": ""2018-01-20T11:17:35+03:00"",
|
||||
""LastBattleTime"": ""2020-02-07T20:03:34+03:00"",
|
||||
""Battles"": 10842,
|
||||
""Wn7"": 1283.4155297487303,
|
||||
""AvgTier"": 7.364785095000922,
|
||||
""Winrate"": 54.75926950747095,
|
||||
""AvgDamage"": 1266.5282235749862,
|
||||
""AvgXp"": 663.4533296439771,
|
||||
""Achievements"": [
|
||||
{
|
||||
""AchievementId"": ""medalHalonen"",
|
||||
""Section"": ""epic"",
|
||||
""Name"": ""Halonen's Medal (medalHalonen)\r\nDestroy at least 3 enemy vehicles with a tank destroyer in one battle."",
|
||||
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalHalonen.png"",
|
||||
""Count"": 3
|
||||
},
|
||||
{
|
||||
""AchievementId"": ""medalLehvaslaiho"",
|
||||
""Section"": ""epic"",
|
||||
""Name"": ""Lehväslaiho's Medal (medalLehvaslaiho)\r\nDestroy 2 enemy vehicles with a medium tank in one battle."",
|
||||
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalLehvaslaiho.png"",
|
||||
""Count"": 47
|
||||
},
|
||||
{
|
||||
""AchievementId"": ""markOfMastery"",
|
||||
""Section"": ""battle"",
|
||||
""Name"": ""Mastery badge: \nAce Tanker (markOfMastery)\r\nProve your mastery in controlling a vehicle. Earn more XP in a battle than the average highest XP of 99% of players who have fought in this vehicle for the previous 7 days."",
|
||||
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/markOfMastery.png"",
|
||||
""Count"": 73
|
||||
},
|
||||
{
|
||||
""AchievementId"": ""medalKolobanov"",
|
||||
""Section"": ""epic"",
|
||||
""Name"": ""Kolobanov's Medal (medalKolobanov)\r\nStand alone against 3 enemy vehicles and win."",
|
||||
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalKolobanov.png"",
|
||||
""Count"": 6
|
||||
},
|
||||
{
|
||||
""AchievementId"": ""medalLafayettePool"",
|
||||
""Section"": ""epic"",
|
||||
""Name"": ""Pool's Medal (medalLafayettePool)\r\nDestroy 6 enemy vehicles in one battle."",
|
||||
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalLafayettePool.png"",
|
||||
""Count"": 7
|
||||
},
|
||||
{
|
||||
""AchievementId"": ""medalOrlik"",
|
||||
""Section"": ""epic"",
|
||||
""Name"": ""Orlik's Medal (medalOrlik)\r\nDestroy at least 3 enemy vehicles with a light tank in one battle."",
|
||||
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalOrlik.png"",
|
||||
""Count"": 4
|
||||
},
|
||||
{
|
||||
""AchievementId"": ""medalRadleyWalters"",
|
||||
""Section"": ""epic"",
|
||||
""Name"": ""Radley-Walters's Medal (medalRadleyWalters)\r\nDestroy 5 enemy vehicles in one battle."",
|
||||
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalRadleyWalters.png"",
|
||||
""Count"": 33
|
||||
},
|
||||
{
|
||||
""AchievementId"": ""medalOskin"",
|
||||
""Section"": ""epic"",
|
||||
""Name"": ""Oskin's Medal (medalOskin)\r\nDestroy 3 enemy vehicles with a medium tank in one battle."",
|
||||
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalOskin.png"",
|
||||
""Count"": 6
|
||||
},
|
||||
{
|
||||
""AchievementId"": ""medalNikolas"",
|
||||
""Section"": ""epic"",
|
||||
""Name"": ""Nicols's Medal (medalNikolas)\r\nDestroy at least 4 enemy vehicles with a medium tank in one battle."",
|
||||
""Image"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/achievements/medalNikolas.png"",
|
||||
""Count"": 1
|
||||
}
|
||||
],
|
||||
""TopTanks"": [
|
||||
{
|
||||
""TankId"": 59905,
|
||||
""MarkOfMastery"": 4,
|
||||
""Battles"": 769,
|
||||
""WinRate"": 57.737321196358907672301690507,
|
||||
""AvgDamage"": 1378.6579973992197659297789337,
|
||||
""AvgXp"": 764.92847854356306892067620286,
|
||||
""Name"": ""T-54 first prototype"",
|
||||
""Tier"": 8,
|
||||
""TierRoman"": ""VIII"",
|
||||
""Nation"": ""ussr"",
|
||||
""Type"": ""mediumTank"",
|
||||
""IsPremium"": true,
|
||||
""PreviewImageUrl"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/uploaded/vehicles/hd_thumbnail/R112_T54_45.png""
|
||||
},
|
||||
{
|
||||
""TankId"": 13345,
|
||||
""MarkOfMastery"": 4,
|
||||
""Battles"": 662,
|
||||
""WinRate"": 55.287009063444108761329305136,
|
||||
""AvgDamage"": 1344.1555891238670694864048338,
|
||||
""AvgXp"": 776.1495468277945619335347432,
|
||||
""Name"": ""T26E4 SuperPershing"",
|
||||
""Tier"": 8,
|
||||
""TierRoman"": ""VIII"",
|
||||
""Nation"": ""usa"",
|
||||
""Type"": ""mediumTank"",
|
||||
""IsPremium"": true,
|
||||
""PreviewImageUrl"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/uploaded/vehicles/hd_thumbnail/T26_E4_SuperPershing.png""
|
||||
},
|
||||
{
|
||||
""TankId"": 9217,
|
||||
""MarkOfMastery"": 4,
|
||||
""Battles"": 439,
|
||||
""WinRate"": 55.808656036446469248291571754,
|
||||
""AvgDamage"": 1493.7220956719817767653758542,
|
||||
""AvgXp"": 737.12072892938496583143507973,
|
||||
""Name"": ""IS-6"",
|
||||
""Tier"": 8,
|
||||
""TierRoman"": ""VIII"",
|
||||
""Nation"": ""ussr"",
|
||||
""Type"": ""heavyTank"",
|
||||
""IsPremium"": true,
|
||||
""PreviewImageUrl"": ""http://glossary-ru-static.gcdn.co/icons/wotb/current/uploaded/vehicles/hd_thumbnail/Object252.png""
|
||||
}
|
||||
]
|
||||
}
|
||||
";
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,10 @@ using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using WotBlitzStatistics.GraphQl.ObjectTypes;
|
||||
using WotBlitzStatistics.GraphQl.Query;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.WgApiClient;
|
||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||
|
||||
namespace WotBlitzStatistics.GraphQl
|
||||
{
|
||||
@@ -40,10 +41,10 @@ namespace WotBlitzStatistics.GraphQl
|
||||
.AddQueryType<WotBlitzStatisticsQuery>()
|
||||
//.AddMutationType<MutationType>()
|
||||
//.AddSubscriptionType<SubscriptionType>()
|
||||
.AddType<PlayerAccountInfo>()
|
||||
.AddType<PlayerAchievementInfo>()
|
||||
.AddType<PlayerTankInfo>()
|
||||
.AddEnumType<MarkOfMastery>()
|
||||
.AddType<PlayerAccountInfoObjectType>()
|
||||
.AddType<AccountStatistics>()
|
||||
.AddType<AccountFullStatistics>()
|
||||
//.AddEnumType<MarkOfMastery>()
|
||||
.Create());
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WotBlitzStatisticsPro.Common\WotBlitzStatisticsPro.Common.csproj" />
|
||||
<ProjectReference Include="..\WotBlitzStatisticsPro.WgApiClient\WotBlitzStatisticsPro.WgApiClient.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WotBlitzStatisticsPro.WgApiClient.Model
|
||||
{
|
||||
@@ -86,13 +83,13 @@ namespace WotBlitzStatisticsPro.WgApiClient.Model
|
||||
public long? MaxXpTankId { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// Totla shots count
|
||||
/// Total shots count
|
||||
///</summary>
|
||||
[JsonProperty("shots")]
|
||||
public long? Shots { get; set; }
|
||||
|
||||
///<summary>
|
||||
/// Totla count of spotted vehicles
|
||||
/// Total count of spotted vehicles
|
||||
///</summary>
|
||||
[JsonProperty("spotted")]
|
||||
public long? Spotted { get; set; }
|
||||
|
||||
Reference in new issue
Block a user