From 8bb3f6ef026a08d6071464231aaf27eabcd1df4d Mon Sep 17 00:00:00 2001 From: yjhmelody Date: Fri, 27 Sep 2024 18:24:08 +0800 Subject: [PATCH 1/5] chore: improve `averageGasPrice` --- stats/stats/src/charts/lines/average_gas_price.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/stats/stats/src/charts/lines/average_gas_price.rs b/stats/stats/src/charts/lines/average_gas_price.rs index f1a8b31ee..d18af79ac 100644 --- a/stats/stats/src/charts/lines/average_gas_price.rs +++ b/stats/stats/src/charts/lines/average_gas_price.rs @@ -60,7 +60,7 @@ impl StatementFromRange for AverageGasPriceStatement { t_filtered.max_fee_per_gas - b.base_fee_per_gas ) ) - ) / $1)::float as value + ) / $1)::TEXT as value FROM ( SELECT * from transactions t WHERE @@ -89,7 +89,7 @@ impl StatementFromRange for AverageGasPriceStatement { transactions.max_fee_per_gas - blocks.base_fee_per_gas ) ) - ) / $1)::float as value + ) / $1)::TEXT as value FROM transactions JOIN blocks ON transactions.block_hash = blocks.hash WHERE @@ -108,8 +108,6 @@ impl StatementFromRange for AverageGasPriceStatement { pub type AverageGasPriceRemote = RemoteDatabaseSource>; -pub type AverageGasPriceRemoteString = MapToString; - pub struct Properties; impl Named for Properties { @@ -136,7 +134,7 @@ define_and_impl_resolution_properties!( ); pub type AverageGasPrice = - DirectVecLocalDbChartSource; + DirectVecLocalDbChartSource; pub type AverageGasPriceWeekly = DirectVecLocalDbChartSource< MapToString, NewTxnsInt, Week>>, Batch30Weeks, From 923da3cf1d04bc61a9f9fde2b88114eaabe25c08 Mon Sep 17 00:00:00 2001 From: yjh Date: Sun, 29 Sep 2024 10:18:40 +0800 Subject: [PATCH 2/5] Update stats/stats/src/charts/lines/average_gas_price.rs Co-authored-by: Kirill Ivanov <8144358+bragov4ik@users.noreply.github.com> --- stats/stats/src/charts/lines/average_gas_price.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stats/stats/src/charts/lines/average_gas_price.rs b/stats/stats/src/charts/lines/average_gas_price.rs index d18af79ac..2ac634e0d 100644 --- a/stats/stats/src/charts/lines/average_gas_price.rs +++ b/stats/stats/src/charts/lines/average_gas_price.rs @@ -106,7 +106,7 @@ impl StatementFromRange for AverageGasPriceStatement { } pub type AverageGasPriceRemote = - RemoteDatabaseSource>; + RemoteDatabaseSource>; pub struct Properties; From 43b9950eb6ed73cbedb3485467864f6257574e97 Mon Sep 17 00:00:00 2001 From: yjhmelody Date: Sun, 29 Sep 2024 11:50:46 +0800 Subject: [PATCH 3/5] chore: replace all `::float` by `::TEXT` --- stats/stats/src/charts/counters/average_block_time.rs | 8 +++----- stats/stats/src/charts/lines/native_coin_supply.rs | 10 ++++------ stats/stats/src/charts/lines/txns_success_rate.rs | 8 +++----- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/stats/stats/src/charts/counters/average_block_time.rs b/stats/stats/src/charts/counters/average_block_time.rs index c79feecc0..4390c01d6 100644 --- a/stats/stats/src/charts/counters/average_block_time.rs +++ b/stats/stats/src/charts/counters/average_block_time.rs @@ -23,7 +23,7 @@ impl StatementForOne for AverageBlockTimeStatement { r#" SELECT max(timestamp)::date as date, - (CASE WHEN avg(diff) IS NULL THEN 0 ELSE avg(diff) END)::float as value + (CASE WHEN avg(diff) IS NULL THEN 0 ELSE avg(diff) END)::TEXT as value FROM ( SELECT @@ -41,9 +41,7 @@ impl StatementForOne for AverageBlockTimeStatement { } pub type AverageBlockTimeRemote = - RemoteDatabaseSource>; - -pub type AverageBlockTimeRemoteString = MapToString; + RemoteDatabaseSource>; pub struct Properties; @@ -64,7 +62,7 @@ impl ChartProperties for Properties { } } -pub type AverageBlockTime = DirectPointLocalDbChartSource; +pub type AverageBlockTime = DirectPointLocalDbChartSource; #[cfg(test)] mod tests { diff --git a/stats/stats/src/charts/lines/native_coin_supply.rs b/stats/stats/src/charts/lines/native_coin_supply.rs index 8b86f6a6e..01858ce01 100644 --- a/stats/stats/src/charts/lines/native_coin_supply.rs +++ b/stats/stats/src/charts/lines/native_coin_supply.rs @@ -51,7 +51,7 @@ impl StatementFromRange for NativeCoinSupplyStatement { WHEN address_hash = '\x0000000000000000000000000000000000000000' THEN -value ELSE value END - ) / $1)::float AS value + ) / $1)::TEXT AS value FROM address_coin_balances_daily WHERE day != to_timestamp(0) AND day <= $3 AND @@ -74,7 +74,7 @@ impl StatementFromRange for NativeCoinSupplyStatement { WHEN address_hash = '\x0000000000000000000000000000000000000000' THEN -value ELSE value END - ) / $1)::float AS value + ) / $1)::TEXT AS value FROM address_coin_balances_daily WHERE day != to_timestamp(0) GROUP BY day @@ -89,9 +89,7 @@ impl StatementFromRange for NativeCoinSupplyStatement { // query returns float value pub type NativeCoinSupplyRemote = - RemoteDatabaseSource>; - -pub type NativeCoinSupplyRemoteString = MapToString; + RemoteDatabaseSource>; pub struct Properties; @@ -119,7 +117,7 @@ define_and_impl_resolution_properties!( ); pub type NativeCoinSupply = - DirectVecLocalDbChartSource; + DirectVecLocalDbChartSource; pub type NativeCoinSupplyWeekly = DirectVecLocalDbChartSource< LastValueLowerResolution, Batch30Weeks, diff --git a/stats/stats/src/charts/lines/txns_success_rate.rs b/stats/stats/src/charts/lines/txns_success_rate.rs index 3bb543605..40f8b6db5 100644 --- a/stats/stats/src/charts/lines/txns_success_rate.rs +++ b/stats/stats/src/charts/lines/txns_success_rate.rs @@ -43,7 +43,7 @@ impl StatementFromRange for TxnsSuccessRateStatement { SELECT DATE(t.block_timestamp) as date, COUNT(CASE WHEN t.error IS NULL THEN 1 END)::FLOAT - / COUNT(*)::FLOAT as value + / COUNT(*)::TEXT as value FROM transactions t WHERE t.block_timestamp != to_timestamp(0) AND @@ -82,9 +82,7 @@ impl StatementFromRange for TxnsSuccessRateStatement { } pub type TxnsSuccessRateRemote = - RemoteDatabaseSource>; - -pub type TxnsSuccessRateRemoteString = MapToString; + RemoteDatabaseSource>; pub struct Properties; @@ -112,7 +110,7 @@ define_and_impl_resolution_properties!( ); pub type TxnsSuccessRate = - DirectVecLocalDbChartSource; + DirectVecLocalDbChartSource; pub type TxnsSuccessRateWeekly = DirectVecLocalDbChartSource< MapToString, NewTxnsInt, Week>>, Batch30Weeks, From 10fd4a683ed47f1d45cf327eb562264dcc5c8931 Mon Sep 17 00:00:00 2001 From: yjhmelody Date: Sun, 29 Sep 2024 14:14:04 +0800 Subject: [PATCH 4/5] fix --- stats/stats/src/charts/lines/txns_success_rate.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stats/stats/src/charts/lines/txns_success_rate.rs b/stats/stats/src/charts/lines/txns_success_rate.rs index 40f8b6db5..15a67889b 100644 --- a/stats/stats/src/charts/lines/txns_success_rate.rs +++ b/stats/stats/src/charts/lines/txns_success_rate.rs @@ -42,8 +42,8 @@ impl StatementFromRange for TxnsSuccessRateStatement { r#" SELECT DATE(t.block_timestamp) as date, - COUNT(CASE WHEN t.error IS NULL THEN 1 END)::FLOAT - / COUNT(*)::TEXT as value + (COUNT(CASE WHEN t.error IS NULL THEN 1 END)::FLOAT + / COUNT(*)::FLOAT)::TEXT as value FROM transactions t WHERE t.block_timestamp != to_timestamp(0) AND @@ -62,8 +62,8 @@ impl StatementFromRange for TxnsSuccessRateStatement { r#" SELECT DATE(b.timestamp) as date, - COUNT(CASE WHEN t.error IS NULL THEN 1 END)::FLOAT - / COUNT(*)::FLOAT as value + (COUNT(CASE WHEN t.error IS NULL THEN 1 END)::FLOAT + / COUNT(*)::FLOAT)::TEXT as value FROM transactions t JOIN blocks b ON t.block_hash = b.hash WHERE From b983dc201fb058121e6b6693711937f73fc7b0a8 Mon Sep 17 00:00:00 2001 From: yjhmelody Date: Mon, 30 Sep 2024 10:55:46 +0800 Subject: [PATCH 5/5] clippy --- stats/stats/src/charts/counters/average_block_time.rs | 1 - stats/stats/src/charts/lines/native_coin_supply.rs | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/stats/stats/src/charts/counters/average_block_time.rs b/stats/stats/src/charts/counters/average_block_time.rs index 4390c01d6..59b45d934 100644 --- a/stats/stats/src/charts/counters/average_block_time.rs +++ b/stats/stats/src/charts/counters/average_block_time.rs @@ -1,7 +1,6 @@ use crate::{ data_source::{ kinds::{ - data_manipulation::map::MapToString, local_db::DirectPointLocalDbChartSource, remote_db::{PullOne, RemoteDatabaseSource, StatementForOne}, }, diff --git a/stats/stats/src/charts/lines/native_coin_supply.rs b/stats/stats/src/charts/lines/native_coin_supply.rs index 01858ce01..1187483e4 100644 --- a/stats/stats/src/charts/lines/native_coin_supply.rs +++ b/stats/stats/src/charts/lines/native_coin_supply.rs @@ -3,9 +3,7 @@ use std::ops::Range; use crate::{ data_source::{ kinds::{ - data_manipulation::{ - map::MapToString, resolutions::last_value::LastValueLowerResolution, - }, + data_manipulation::resolutions::last_value::LastValueLowerResolution, local_db::{ parameters::update::batching::parameters::{ Batch30Days, Batch30Weeks, Batch30Years, Batch36Months,