MostlyData_Slot fee mod4 by leader
    Updated 2025-01-21
    with leader_blocks_fee as(
    select
    block_id,
    reward_amount_sol

    from solana.gov.fact_rewards_fee

    where
    pubkey = '{{leader}}'
    and ( (
    '{{n_days}}' = 0
    and block_timestamp >= cast('{{start_date}}' as timestamp)
    and block_timestamp < cast('{{end_date}}' as timestamp)
    )
    or
    (
    '{{n_days}}' != 0
    and block_timestamp > current_date() - interval '{{n_days}} days'
    ))
    and reward_amount_sol < '{{fee_threshold}}'

    )

    ,ordered_slots as (
    select
    *,
    row_number() over (order by block_id) as row_num
    from leader_blocks_fee
    )

    ,grouped_slots as (
    select
    block_id,
    reward_amount_sol,
    floor((row_number() over (order by block_id) - 1) / 4) as group_id,
    QueryRunArchived: QueryRun has been archived