jackguyNear Social Dashboard 7 copy
    Updated 2023-03-13
    -- forked from 9da86ee6-25f3-4d63-8f9a-fc98b5af914e
    with tab1 as (
    SELECT
    signer_id,
    min(date_trunc('day', block_timestamp)) as first_day,
    count(DISTINCT tx_hash) as profile_change_events
    FROM near.social.fact_addkey_events
    GROUP BY 1
    )



    SELECT
    avg(users),
    median(users)

    FROM (
    SELECT
    date_trunc('week', block_timestamp) as week,
    count(DISTINCT SIGNER_ID) as users,
    count(DISTINCT tx_hash) as events

    FROM near.social.fact_decoded_actions
    WHERE signer_id in (
    SELECT
    DISTINCT signer_id
    FROM tab1
    WHERE first_day BETWEEN '{{ user_group_first_day }}' AND '{{ user_group_last_day }}'
    )
    GROUP BY 1
    )


    Run a query to Download Data