MasiTotal Votes per vote option
    Updated 2022-12-14
    with operator as ( select REPLACE(ATTRIBUTE_VALUE, 'valoper', '') as cos_address ,
    left(cos_address, 30) as short_validator
    from cosmos.core.fact_msg_attributes
    where ATTRIBUTE_KEY = 'validator')
    ,
    shorted_address as ( select block_timestamp,
    left(tx_from,30) as short_validator ,
    tx_id
    from cosmos.core.fact_transactions
    where tx_id in (select tx_id
    from cosmos.core.fact_msg_attributes
    where ATTRIBUTE_KEY = 'proposal_id'))
    ,
    validator_vote as ( select DISTINCT a.tx_id
    from shorted_address a join operator b on a.short_validator = b.short_validator )
    ,
    prop_options as ( select a.block_timestamp,
    TX_FROM,
    a.tx_id,
    try_parse_json (attribute_value) info,
    info:option as voted, case when voted = 1 then 'YES'
    when voted = 2 then 'Abstain'
    when voted = 3 then 'No'
    when voted = 4 then 'No With Veto' end as votes
    from cosmos.core.fact_msg_attributes a join cosmos.core.fact_transactions b on a.tx_id = b.tx_id
    where ATTRIBUTE_KEY = 'option' and b.TX_SUCCEEDED = 'TRUE')
    ,
    prop_num as ( select a.block_timestamp,
    tx_from,
    b.tx_id,
    ATTRIBUTE_VALUE as prop_num,
    votes
    from cosmos.core.fact_msg_attributes a join prop_options b on a.tx_id = b.tx_id
    where ATTRIBUTE_KEY = 'proposal_id')
    ,
    new_voters as ( select tx_from,
    Run a query to Download Data