Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(stats): replace all ::float by ::TEXT #1071

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions stats/stats/src/charts/counters/average_block_time.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{
data_source::{
kinds::{
data_manipulation::map::MapToString,
local_db::DirectPointLocalDbChartSource,
remote_db::{PullOne, RemoteDatabaseSource, StatementForOne},
},
Expand All @@ -23,7 +22,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
Expand All @@ -41,9 +40,7 @@ impl StatementForOne for AverageBlockTimeStatement {
}

pub type AverageBlockTimeRemote =
RemoteDatabaseSource<PullOne<AverageBlockTimeStatement, NaiveDate, f64>>;

pub type AverageBlockTimeRemoteString = MapToString<AverageBlockTimeRemote>;
RemoteDatabaseSource<PullOne<AverageBlockTimeStatement, NaiveDate, String>>;

pub struct Properties;

Expand All @@ -64,7 +61,7 @@ impl ChartProperties for Properties {
}
}

pub type AverageBlockTime = DirectPointLocalDbChartSource<AverageBlockTimeRemoteString, Properties>;
pub type AverageBlockTime = DirectPointLocalDbChartSource<AverageBlockTimeRemote, Properties>;

#[cfg(test)]
mod tests {
Expand Down
10 changes: 4 additions & 6 deletions stats/stats/src/charts/lines/average_gas_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -106,9 +106,7 @@ impl StatementFromRange for AverageGasPriceStatement {
}

pub type AverageGasPriceRemote =
RemoteDatabaseSource<PullAllWithAndSort<AverageGasPriceStatement, NaiveDate, f64>>;

pub type AverageGasPriceRemoteString = MapToString<AverageGasPriceRemote>;
RemoteDatabaseSource<PullAllWithAndSort<AverageGasPriceStatement, NaiveDate, String>>;

pub struct Properties;

Expand Down Expand Up @@ -136,7 +134,7 @@ define_and_impl_resolution_properties!(
);

pub type AverageGasPrice =
DirectVecLocalDbChartSource<AverageGasPriceRemoteString, Batch30Days, Properties>;
DirectVecLocalDbChartSource<AverageGasPriceRemote, Batch30Days, Properties>;
pub type AverageGasPriceWeekly = DirectVecLocalDbChartSource<
MapToString<AverageLowerResolution<MapParseTo<AverageGasPrice, f64>, NewTxnsInt, Week>>,
Batch30Weeks,
Expand Down
14 changes: 5 additions & 9 deletions stats/stats/src/charts/lines/native_coin_supply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -51,7 +49,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
Expand All @@ -74,7 +72,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
Expand All @@ -89,9 +87,7 @@ impl StatementFromRange for NativeCoinSupplyStatement {

// query returns float value
pub type NativeCoinSupplyRemote =
RemoteDatabaseSource<PullAllWithAndSort<NativeCoinSupplyStatement, NaiveDate, f64>>;

pub type NativeCoinSupplyRemoteString = MapToString<NativeCoinSupplyRemote>;
RemoteDatabaseSource<PullAllWithAndSort<NativeCoinSupplyStatement, NaiveDate, String>>;

pub struct Properties;

Expand Down Expand Up @@ -119,7 +115,7 @@ define_and_impl_resolution_properties!(
);

pub type NativeCoinSupply =
DirectVecLocalDbChartSource<NativeCoinSupplyRemoteString, Batch30Days, Properties>;
DirectVecLocalDbChartSource<NativeCoinSupplyRemote, Batch30Days, Properties>;
pub type NativeCoinSupplyWeekly = DirectVecLocalDbChartSource<
LastValueLowerResolution<NativeCoinSupply, Week>,
Batch30Weeks,
Expand Down
14 changes: 6 additions & 8 deletions stats/stats/src/charts/lines/txns_success_rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(*)::FLOAT 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
Expand All @@ -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
Expand All @@ -82,9 +82,7 @@ impl StatementFromRange for TxnsSuccessRateStatement {
}

pub type TxnsSuccessRateRemote =
RemoteDatabaseSource<PullAllWithAndSort<TxnsSuccessRateStatement, NaiveDate, f64>>;

pub type TxnsSuccessRateRemoteString = MapToString<TxnsSuccessRateRemote>;
RemoteDatabaseSource<PullAllWithAndSort<TxnsSuccessRateStatement, NaiveDate, String>>;

pub struct Properties;

Expand Down Expand Up @@ -112,7 +110,7 @@ define_and_impl_resolution_properties!(
);

pub type TxnsSuccessRate =
DirectVecLocalDbChartSource<TxnsSuccessRateRemoteString, Batch30Days, Properties>;
DirectVecLocalDbChartSource<TxnsSuccessRateRemote, Batch30Days, Properties>;
pub type TxnsSuccessRateWeekly = DirectVecLocalDbChartSource<
MapToString<AverageLowerResolution<MapParseTo<TxnsSuccessRate, f64>, NewTxnsInt, Week>>,
Batch30Weeks,
Expand Down
Loading