kaibladeGrant Payout Stats
    Updated 2023-03-19
    WITH to_dao AS
    (SELECT *
    FROM near.core.fact_transactions
    WHERE tx_receiver = 'marketing.sputnik-dao.near'
    AND block_timestamp::date BETWEEN '{{Start_Date}}' AND '{{End_Date}}'),
    dao_tx AS
    (SELECT event.block_id, event.tx_hash, event.block_timestamp, event.method_name,
    tx.tx_receiver, tx.tx_signer, event.deposit/1e24 AS deposit, PARSE_JSON(event.args) AS args, tx.tx_status
    FROM near.core.fact_actions_events_function_call event
    JOIN to_dao tx
    ON event.tx_hash = tx.tx_hash
    ORDER BY block_timestamp DESC),


    act_proposals1 AS
    (SELECT tx_hash, block_timestamp,
    tx_signer, args, args:action AS action, args:id AS proposal_id, tx_status
    FROM dao_tx
    WHERE method_name = 'act_proposal'
    ORDER BY block_timestamp DESC),

    act_proposals_receipts AS
    (SELECT *
    FROM near.core.fact_receipts
    WHERE receiver_id = 'marketing.sputnik-dao.near'
    AND block_timestamp::date BETWEEN '{{Start_Date}}' AND '{{End_Date}}'
    AND tx_hash NOT IN (SELECT tx_hash FROM act_proposals1)
    AND LEN(status_value:SuccessValue) = 0),

    extra_act_proposals AS
    (SELECT tx_hash, block_timestamp, actions:predecessor_id AS tx_signer, parse_json(try_base64_decode_string(actions:receipt.Action.actions[0].FunctionCall.args)) AS args,
    args:action AS action, args:id AS proposal_id, 'Success' AS tx_status
    FROM act_proposals_receipts),

    act_proposals AS
    Run a query to Download Data