Sandeshflow_nft users dau
    Updated 2022-11-30
    with flow_price as
    (
    select date_trunc('{{granularity}}',timestamp) as time,token_contract, avg(price_usd) as usd_price
    from flow.core.fact_prices
    group by time, token_contract
    ),
    flow_nfts as
    (
    select
    'flow' as chain,
    date_trunc('{{granularity}}',block_timestamp) as time,
    nft.tx_id as tx_hash,
    ad.contract_name as marketplace,
    seller,
    buyer,
    ad2.contract_name as project_name,
    nft_id as token_id,
    currency,
    case when currency='A.ead892083b3e2c6c.DapperUtilityCoin' then 1*nft.price
    else nft.price*p.usd_price
    end as price
    from flow.core.ez_nft_sales nft left join flow_price p
    on (nft.currency=p.token_contract and date_trunc('{{granularity}}',block_timestamp) = p.time )
    left join flow.core.dim_contract_labels ad on nft.marketplace=ad.event_contract
    left join flow.core.dim_contract_labels ad2 on nft.nft_collection =ad2.event_contract
    where time between '{{start_date}}' and '{{end_date}}'

    ),
    daus as (
    SELECT
    distinct buyer as users,
    trunc(time,'week') as weeks,
    count(distinct trunc(time,'day')) as active_days
    from flow_nfts
    Run a query to Download Data