with fix_parameter as (
select
case
when '{{Days}}' = 'Last 90 Days' then 90
when '{{Days}}' = 'Last 180 Days' then 180
when '{{Days}}' = 'Last 360 Days' then 360
when '{{Days}}' = 'All Time' then 2000
else 90
end as time_frame
)
select
date_trunc('{{Date_Trunc}}', block_timestamp) as "Date",
count(distinct tx_hash) as num_tx,
num_tx / 86400 as "TPS"
from optimism.core.fact_transactions
where block_timestamp::date >= current_date - (select time_frame from fix_parameter)
and block_timestamp::date <= current_date - 1
group by "Date"