diff --git a/src/data/daily_providers_metrics.csv.sh b/src/data/daily_providers_metrics.csv.sh index c880196..5ecb709 100644 --- a/src/data/daily_providers_metrics.csv.sh +++ b/src/data/daily_providers_metrics.csv.sh @@ -4,27 +4,21 @@ duckdb :memory: << EOF SET enable_progress_bar = false; COPY ( - with retrieval_rates as ( - select - date, - provider_id, - case - when total_retrieval_requests > 0 - then successful_retrieval_requests * 1.0 / total_retrieval_requests - else 0 - end as retrieval_rate, - sector_health_rate, + with base as ( + select + date, + provider_id, + spark_retrieval_success_rate, + sector_health_rate, from read_parquet('https://data.filecoindataportal.xyz/filecoin_daily_storage_providers_metrics.parquet') - where date >= current_date() - interval '90 days' + where date >= current_date() - interval '90 days' ) select date, - count(distinct case when retrieval_rate > 0.9 then provider_id end) as meet_retrieval_sli, - count(distinct case when retrieval_rate > 0.9 then provider_id end) * 1.0 / count(distinct provider_id) as meet_retrieval_sli_percent, - count(distinct provider_id) filter (where sector_health_rate * 100 > 95) as meet_sector_health_sli, - count(distinct provider_id) filter (where sector_health_rate * 100 > 95) * 1.0 / count(distinct provider_id) as meet_sector_health_sli_percent - from retrieval_rates r + count(distinct provider_id) filter (where spark_retrieval_success_rate > 0.90) as meet_retrieval_sli, + count(distinct provider_id) filter (where sector_health_rate between 0.95 and 1.00) as meet_sector_health_sli, + from base group by date order by date desc ) TO STDOUT (FORMAT 'CSV');