From d518797e5546fc6644f68cbb30ec8e785b55c917 Mon Sep 17 00:00:00 2001 From: area363 Date: Thu, 13 May 2021 20:12:50 +0900 Subject: [PATCH 1/3] adjust mysql schema --- .../GraphQL/Types/HackAndSlashType.cs | 1 + NineChronicles.DataProvider/RenderSubscriber.cs | 5 ++++- .../Store/Models/HackAndSlashModel.cs | 2 ++ NineChronicles.DataProvider/Store/MySqlStore.cs | 4 +++- sql/initialize-database.sql | 1 + 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/NineChronicles.DataProvider/GraphQL/Types/HackAndSlashType.cs b/NineChronicles.DataProvider/GraphQL/Types/HackAndSlashType.cs index aa77e9ee..d8c4bb58 100644 --- a/NineChronicles.DataProvider/GraphQL/Types/HackAndSlashType.cs +++ b/NineChronicles.DataProvider/GraphQL/Types/HackAndSlashType.cs @@ -11,6 +11,7 @@ public HackAndSlashType() Field(x => x.Avatar_Address); Field(x => x.Stage_Id); Field(x => x.Cleared); + Field(x => x.Block_Hash); Name = "HackAndSlash"; } diff --git a/NineChronicles.DataProvider/RenderSubscriber.cs b/NineChronicles.DataProvider/RenderSubscriber.cs index f39e4c93..ea16aa28 100644 --- a/NineChronicles.DataProvider/RenderSubscriber.cs +++ b/NineChronicles.DataProvider/RenderSubscriber.cs @@ -1,3 +1,5 @@ +using System.Reactive; + namespace NineChronicles.DataProvider { using System; @@ -53,7 +55,8 @@ protected override Task ExecuteAsync(CancellationToken stoppingToken) ev.Signer.ToString(), action.avatarAddress.ToString(), action.stageId, - action.Result.IsClear + action.Result.IsClear, + ev.BlockHash.ToString() ); Log.Debug("Stored HackAndSlash action in block #{0}", ev.BlockIndex); } diff --git a/NineChronicles.DataProvider/Store/Models/HackAndSlashModel.cs b/NineChronicles.DataProvider/Store/Models/HackAndSlashModel.cs index e2eb66f2..f7551215 100644 --- a/NineChronicles.DataProvider/Store/Models/HackAndSlashModel.cs +++ b/NineChronicles.DataProvider/Store/Models/HackAndSlashModel.cs @@ -9,5 +9,7 @@ public struct HackAndSlashModel public int Stage_Id { get; set; } public bool Cleared { get; set; } + + public string Block_Hash { get; set; } } } diff --git a/NineChronicles.DataProvider/Store/MySqlStore.cs b/NineChronicles.DataProvider/Store/MySqlStore.cs index e99b905a..7fd9ca94 100644 --- a/NineChronicles.DataProvider/Store/MySqlStore.cs +++ b/NineChronicles.DataProvider/Store/MySqlStore.cs @@ -51,7 +51,8 @@ public void StoreHackAndSlash( string agentAddress, string avatarAddress, int stageId, - bool cleared) + bool cleared, + string blockHash) { Insert(HackAndSlashDbName, new Dictionary { @@ -59,6 +60,7 @@ public void StoreHackAndSlash( ["avatar_address"] = avatarAddress, ["stage_id"] = stageId, ["cleared"] = cleared, + ["block_hash"] = blockHash, }); } diff --git a/sql/initialize-database.sql b/sql/initialize-database.sql index 55868be8..3b9d08d3 100644 --- a/sql/initialize-database.sql +++ b/sql/initialize-database.sql @@ -22,6 +22,7 @@ CREATE TABLE IF NOT EXISTS `data_provider`.`hack_and_slash` ( `agent_address` VARCHAR NOT NULL, `stage_id` INT NOT NULL, `cleared` BOOLEAN NOT NULL, + `block_hash` VARCHAR NOT NULL, INDEX `fk_hack_and_slash_avatar1_idx` (`avatar_address`), INDEX `fk_hack_and_slash_agent1_idx` (`agent_address`), From 2ad4b39c3a3642c407b49cb2ff325e87d0a083a2 Mon Sep 17 00:00:00 2001 From: area363 Date: Fri, 14 May 2021 10:26:06 +0900 Subject: [PATCH 2/3] add timestamp column --- sql/initialize-database.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/initialize-database.sql b/sql/initialize-database.sql index 3b9d08d3..79fa133b 100644 --- a/sql/initialize-database.sql +++ b/sql/initialize-database.sql @@ -23,6 +23,7 @@ CREATE TABLE IF NOT EXISTS `data_provider`.`hack_and_slash` ( `stage_id` INT NOT NULL, `cleared` BOOLEAN NOT NULL, `block_hash` VARCHAR NOT NULL, + `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, INDEX `fk_hack_and_slash_avatar1_idx` (`avatar_address`), INDEX `fk_hack_and_slash_agent1_idx` (`agent_address`), From c7c255c0627a4b85715a331aa0c01f36de84144f Mon Sep 17 00:00:00 2001 From: area363 Date: Fri, 14 May 2021 10:53:59 +0900 Subject: [PATCH 3/3] remove unnecessary namespace --- NineChronicles.DataProvider/RenderSubscriber.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/NineChronicles.DataProvider/RenderSubscriber.cs b/NineChronicles.DataProvider/RenderSubscriber.cs index ea16aa28..2ce7275f 100644 --- a/NineChronicles.DataProvider/RenderSubscriber.cs +++ b/NineChronicles.DataProvider/RenderSubscriber.cs @@ -1,5 +1,3 @@ -using System.Reactive; - namespace NineChronicles.DataProvider { using System;