-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stats): arbitrum main page charts (#1210)
* add to interface * save 3 seconds on each just test-with-db * add new charts * fix window charts incorrectly updated * remove excess line chart from layout * add the charts everywhere + update configs etc. * fix index status req for new charts * fix warn when arbitrum is disabled * fix warn when calculating yesterday oper txns * test disabled arbitrum * fix warns * clippy
- Loading branch information
Showing
26 changed files
with
661 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,57 @@ | ||
use blockscout_service_launcher::test_server::send_get_request; | ||
|
||
use pretty_assertions::assert_eq; | ||
use stats::{ | ||
lines::{NewTxnsWindow, NEW_TXNS_WINDOW_RANGE}, | ||
Named, | ||
}; | ||
use stats::lines::NEW_TXNS_WINDOW_RANGE; | ||
use stats_proto::blockscout::stats::v1::MainPageStats; | ||
use url::Url; | ||
|
||
use crate::array_of_variables_with_names; | ||
|
||
pub async fn test_main_page_ok(base: Url) { | ||
pub async fn test_main_page_ok(base: Url, expect_arbitrum: bool) { | ||
let main_page: MainPageStats = send_get_request(&base, "/api/v1/pages/main").await; | ||
let MainPageStats { | ||
average_block_time, | ||
total_addresses, | ||
total_blocks, | ||
total_transactions, | ||
yesterday_transactions, | ||
total_operational_transactions, | ||
yesterday_operational_transactions, | ||
daily_new_transactions, | ||
daily_new_operational_transactions, | ||
} = main_page; | ||
let counters = array_of_variables_with_names!([ | ||
let mut counters = array_of_variables_with_names!([ | ||
average_block_time, | ||
total_addresses, | ||
total_blocks, | ||
total_transactions, | ||
yesterday_transactions, | ||
]); | ||
]) | ||
.to_vec(); | ||
if expect_arbitrum { | ||
counters.extend(array_of_variables_with_names!([ | ||
total_operational_transactions, | ||
yesterday_operational_transactions, | ||
])); | ||
} | ||
for (name, counter) in counters { | ||
#[allow(clippy::expect_fun_call)] | ||
let counter = counter.expect(&format!("page counter {} must be available", name)); | ||
let counter = counter.unwrap_or_else(|| panic!("page counter {} must be available", name)); | ||
assert!(!counter.description.is_empty()); | ||
assert!(!counter.title.is_empty()); | ||
} | ||
|
||
let daily_new_transactions = | ||
daily_new_transactions.expect("daily new transactions chart must be available"); | ||
let transactions_info = daily_new_transactions.info.unwrap(); | ||
assert_eq!(transactions_info.id, NewTxnsWindow::name()); | ||
assert_eq!(transactions_info.resolutions, vec!["DAY"]); | ||
assert_eq!( | ||
daily_new_transactions.chart.len(), | ||
NEW_TXNS_WINDOW_RANGE as usize | ||
); | ||
let mut window_line_charts = array_of_variables_with_names!([daily_new_transactions]).to_vec(); | ||
if expect_arbitrum { | ||
window_line_charts.extend(array_of_variables_with_names!([ | ||
daily_new_operational_transactions | ||
])); | ||
} | ||
for (name, window_chart) in window_line_charts { | ||
let window_chart = | ||
window_chart.unwrap_or_else(|| panic!("{} chart must be available", name)); | ||
let transactions_info = window_chart.info.unwrap(); | ||
assert!(!transactions_info.id.is_empty()); | ||
assert_eq!(transactions_info.resolutions, vec!["DAY"]); | ||
assert_eq!(window_chart.chart.len(), NEW_TXNS_WINDOW_RANGE as usize); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.