From 49e901beee4e3a235a0e6ba38c87cd1697ac0276 Mon Sep 17 00:00:00 2001 From: moreal Date: Thu, 16 May 2024 03:52:48 +0900 Subject: [PATCH] feat(api): include `dailyRewardReceivedIndex` in the `Models.Agent.Avatar` model --- Mimir.Worker/Scrapper/StateGetter.cs | 5 +++++ Mimir/Controllers/AgentController.cs | 2 +- Mimir/Models/Agent/Avatar.cs | 3 ++- Mimir/Repositories/ArenaRankingRespository.cs | 3 ++- Mimir/Util/StateGetter.cs | 5 +++++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Mimir.Worker/Scrapper/StateGetter.cs b/Mimir.Worker/Scrapper/StateGetter.cs index c448576e..7e30ae4a 100644 --- a/Mimir.Worker/Scrapper/StateGetter.cs +++ b/Mimir.Worker/Scrapper/StateGetter.cs @@ -102,6 +102,11 @@ public async Task GetAvatarState(Address avatarAddress) { avatarState.actionPoint = actionPoint; } + + if (await GetStateWithLegacyAccount(avatarAddress, Addresses.DailyReward) is Integer dailyRewardReceivedIndex) + { + avatarState.dailyRewardReceivedIndex = dailyRewardReceivedIndex; + } return avatarState; } diff --git a/Mimir/Controllers/AgentController.cs b/Mimir/Controllers/AgentController.cs index 78b75d38..28133d29 100644 --- a/Mimir/Controllers/AgentController.cs +++ b/Mimir/Controllers/AgentController.cs @@ -26,7 +26,7 @@ IStateService stateService } return new AvatarsResponse( - avatars.Select(e => new Avatar(e.address.ToString(), e.name, e.level, e.actionPoint)).ToList() + avatars.Select(e => new Avatar(e.address.ToString(), e.name, e.level, e.actionPoint, e.dailyRewardReceivedIndex)).ToList() ); } } diff --git a/Mimir/Models/Agent/Avatar.cs b/Mimir/Models/Agent/Avatar.cs index 1d9e3884..a0b67abc 100644 --- a/Mimir/Models/Agent/Avatar.cs +++ b/Mimir/Models/Agent/Avatar.cs @@ -1,9 +1,10 @@ namespace Mimir.Models.Agent; -public class Avatar(string avatarAddress, string avatarName, int level, int actionPoint) +public class Avatar(string avatarAddress, string avatarName, int level, int actionPoint, long dailyRewardReceivedIndex) { public string AvatarAddress { get; set; } = avatarAddress; public string AvatarName { get; set; } = avatarName; public int Level { get; set; } = level; public int ActionPoint { get; private set; } = actionPoint; + public long DailyRewardReceivedIndex { get; private set; } = dailyRewardReceivedIndex; } diff --git a/Mimir/Repositories/ArenaRankingRespository.cs b/Mimir/Repositories/ArenaRankingRespository.cs index b9ff07f5..509aa7db 100644 --- a/Mimir/Repositories/ArenaRankingRespository.cs +++ b/Mimir/Repositories/ArenaRankingRespository.cs @@ -161,7 +161,8 @@ private async Task BuildArenaRankingFromDocument(BsonDocument docu document["Avatar"]["Avatar"]["address"].AsString, document["Avatar"]["Avatar"]["name"].AsString, document["Avatar"]["Avatar"]["level"].AsInt32, - document["Avatar"]["Avatar"]["actionPoint"].AsInt32 + document["Avatar"]["Avatar"]["actionPoint"].AsInt32, + document["Avatar"]["Avatar"]["dailyRewardReceivedIndex"].AsInt64 ); arenaRanking.Avatar = avatar; diff --git a/Mimir/Util/StateGetter.cs b/Mimir/Util/StateGetter.cs index b9fe54f3..8245f2a3 100644 --- a/Mimir/Util/StateGetter.cs +++ b/Mimir/Util/StateGetter.cs @@ -101,6 +101,11 @@ await stateService.GetState(address, accountAddress) ?? { avatarState.actionPoint = actionPoint; } + + if (await GetStateAsync(avatarAddress, Addresses.DailyReward) is Integer dailyRewardReceivedIndex) + { + avatarState.dailyRewardReceivedIndex = dailyRewardReceivedIndex; + } return avatarState; }