0xHaM-dtop program by Txs[Last Week]
    Updated 2025-03-25
    -- forked from top program by users[Last Week] @ https://flipsidecrypto.xyz/studio/queries/28762100-e9d2-448a-8486-5913a0be3bcd

    -- forked from h4wk / top program by users @ https://flipsidecrypto.xyz/h4wk/q/DogcQDb2C0dc/top-program-by-users


    with events as (
    select
    BLOCK_TIMESTAMP,
    TX_ID,
    program_id,
    signers[0] as user
    from eclipse.core.fact_events_inner
    WHERE block_timestamp::date < trunc(current_date, 'week')
    AND block_timestamp::date >= trunc(current_date, 'week') - 7
    AND succeeded = True
    )
    , inner_events as (
    select
    BLOCK_TIMESTAMP,
    TX_ID,
    program_id,
    signers[0] as user
    from eclipse.core.fact_events
    WHERE block_timestamp::date < trunc(current_date, 'week')
    AND block_timestamp::date >= trunc(current_date, 'week') - 7
    AND succeeded = True
    )
    , combine as (
    select * from events
    UNION ALL
    select * from inner_events
    )

    select
    program_id,
    case
    QueryRunArchived: QueryRun has been archived