Skip to content

Commit

Permalink
refactor: πŸ”„ simplify metrics calculation and filter conditions
Browse files Browse the repository at this point in the history
Replaced custom retrieval rate calculation with spark_retrieval_success_rate. Streamlined filtering conditions for both retrieval and sector health SLIs.
  • Loading branch information
davidgasquez committed Nov 27, 2024
1 parent 7a15044 commit ad4d651
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/data/daily_providers_metrics.csv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit ad4d651

Please sign in to comment.