elsina2024-08-19: Monthly new_user
    Updated 2024-10-19
    with users as (
    SELECT
    signer_id as user,
    min(block_timestamp) as min_date
    from
    near.gov.fact_staking_actions
    where
    action in ('staking', 'unstaking')
    group by
    user
    ),
    new_users as (
    select
    date_trunc('month', min_date) as date,
    count(distinct user) as new_user_count
    from
    users
    group by
    date
    ),
    old_users as (
    select
    date_trunc('month', block_timestamp) as date,
    count(distinct
    case
    when signer_id in (select user from users where date_trunc('month', min_date) = date_trunc('month', block_timestamp))
    then null
    else signer_id
    end
    ) as old_user_count,
    count(distinct signer_id) as total_user_count
    from
    near.gov.fact_staking_actions
    where
    action in ('staking', 'unstaking')
    group by
    QueryRunArchived: QueryRun has been archived