MLDZMNnewusers1 copy
    Updated 2023-11-22
    with t1 as (select
    'Main post' as action_type,
    SIGNER_ID,
    min(block_timestamp) as min_date
    from near.social.fact_decoded_actions
    where BLOCK_TIMESTAMP >= CURRENT_DATE - {{Time_period_days}} and NODE='post'
    and node_data ilike '%main%'
    group by 1,2
    union all
    select
    'Comment' as action_type,
    SIGNER_ID,
    min(block_timestamp) as min_date
    from near.social.fact_decoded_actions
    where BLOCK_TIMESTAMP >= CURRENT_DATE - {{Time_period_days}} and NODE='post'
    and node_data ilike '%comment%'
    group by 1,2
    union all
    select
    'Follow/unfollow' as action_type,
    SIGNER_ID,
    min(block_timestamp) as min_date
    from near.social.fact_decoded_actions
    where BLOCK_TIMESTAMP >= CURRENT_DATE - {{Time_period_days}}
    and node_data:graph ilike '%follow%'
    group by 1,2
    union all
    select
    'Profile actions' as action_type,
    SIGNER_ID,
    min(block_timestamp) as min_date
    from near.social.fact_profile_changes
    where BLOCK_TIMESTAMP >= CURRENT_DATE - {{Time_period_days}}
    group by 1,2
    union all

    Run a query to Download Data