freemartianWeekly Cumulative New & Active Users
    Updated 2022-12-06
    with source as (
    select
    tx_sender,
    min(block_timestamp::date) as first_day
    from terra.core.fact_transactions
    where TX_SUCCEEDED = 'TRUE'
    group by tx_sender)

    select
    'New_Users' as label,
    date_trunc('week', first_day) as TIME,
    count(tx_sender) as count,
    sum(count) over (order by TIME) as cumulative_new_users
    from source
    where first_day >= CURRENT_DATE - {{Past_X_Days}}
    group by label, time

    UNION

    select
    'Active_Users' as label,
    date_trunc('week', block_timestamp::date) as TIME,
    count(distinct tx_sender) as count,
    sum(count) over (order by TIME) as cumulative_active_users
    from terra.core.fact_transactions
    where TX_SUCCEEDED = 'TRUE'
    and block_timestamp >= CURRENT_DATE - {{Past_X_Days}}
    group by label, TIME

    Run a query to Download Data