Metiocreproposals first and last
    Updated 2022-05-24
    -- Return the last 60 days proposal votes
    WITH all_proposals AS
    (SELECT block_timestamp :: DATE AS DATE,
    block_timestamp as time,
    attribute_value AS proposal,
    tx_id
    FROM osmosis.core.fact_msg_attributes
    WHERE block_timestamp > CURRENT_DATE()-60
    AND msg_type = 'proposal_vote'
    AND attribute_key = 'proposal_id')

    -- Count daily terra and non-terra governance votes
    SELECT
    allp.proposal,
    CASE
    WHEN allp.proposal not IN ('172', '222', '223', '224', '225', '226', '227', '228', '230', '234') THEN 'non-terra'
    ELSE 'terra'
    END AS prop_type,
    min(time) as first_time,
    max(time) as last_time,
    timestampdiff(hour,first_time,last_time) as duration
    FROM all_proposals as allp
    GROUP BY allp.proposal

    Run a query to Download Data