PetJokicsHorsesleaederboard
    Updated 2024-11-17
    WITH unique_moments AS (
    SELECT
    NFT_ID AS momentId,
    set_id,
    metadata:FullName AS player,
    serial_number,
    nft_collection,
    play_id
    FROM
    flow.nft.dim_moment_metadata
    WHERE
    metadata:FullName = 'Nikola Jokić'
    OR (momentid = '238283' AND play_id = '376') -- Special case for TSD due to bug in flow.nft.dim_moment_metadata
    ),
    sent_to_pjh AS (
    SELECT
    block_timestamp,
    tx_id,
    COALESCE(
    REGEXP_SUBSTR(script, 'tokenID: ([0-9]+)', 1, 1, 'e', 1),
    '29229965'
    ) AS momentId,
    transaction_result:events[0]:values:value:fields[1]:value:value:value AS sender,
    transaction_result:events[3]:values:value:fields[1]:value:value:value AS recipient
    FROM
    flow.core.fact_transactions
    WHERE
    transaction_result:events[0]:type = 'A.0b2a3299cc857e29.TopShot.Withdraw'
    AND transaction_result:events[3]:type = 'A.0b2a3299cc857e29.TopShot.Deposit'
    AND array_size(transaction_result:events) IN (9)
    AND (recipient = '0xf853bd09d46e7db6' or sender = '0xf853bd09d46e7db6')
    AND block_timestamp >= '2024-11-08 22:00:00.123456789'
    AND block_timestamp < '2024-11-15 22:00:00.123456789'
    )
    SELECT
    CASE
    QueryRunArchived: QueryRun has been archived