with seconds_count as (
select
date_trunc('seconds', block_timestamp) as seconds,
count(tx_id) as tx_count
from terra.core.fact_transactions
where block_timestamp >= current_date - 365
group by seconds
)
select
date_trunc('week', seconds) as week,
avg(tx_count) as avg_tps
from seconds_count
group by week
order by week asc