Sbhn_NPsocial2
    Updated 2023-09-27
    -- forked from rmas / DASH - Weekly User Activity @ https://flipsidecrypto.xyz/rmas/q/BKVSXvY6nkXs/dash---weekly-user-activity

    WITH

    signups AS (
    -- AddKey events are used as proxy for user signup
    -- TX triggered upon first sign in to NEAR Social app
    SELECT tx_hash
    , block_timestamp
    , 'SIGNUP' AS action
    , signer_id AS user_account_id
    FROM near.social.fact_addkey_events
    ),


    profile_updates AS (
    SELECT tx_hash
    , block_timestamp
    , 'UPDATE_PROFILE' AS action
    , signer_id AS user_account_id

    FROM near.social.fact_profile_changes
    QUALIFY row_number() OVER (partition by tx_hash order by True) = 1
    ),


    posts AS (
    SELECT tx_hash
    , action_id_social
    , block_timestamp
    , 'POST' AS action
    , signer_id AS post_author_account_id
    , block_id AS post_block_height
    , post_text
    FROM near.social.fact_posts
    ),
    Run a query to Download Data