LTirrell2022-04-21_terra_votes_backup
    Updated 2022-04-22
    with non_val_voters as (
    select
    date_trunc('day', block_timestamp) as datetime,
    voter,
    proposal_id,
    case
    when option in ('Yes', 'VOTE_OPTION_YES') then 'Yes'
    when option in ('No', 'VOTE_OPTION_NO') then 'No'
    when option in ('Abstain', 'VOTE_OPTION_ABSTAIN') then 'Abstain'
    when option in ('NoWithVeto', 'VOTE_OPTION_NO_WITH_VETO') then 'NoWithVeto'
    end as option,
    -- voting_power, -- not using, empty a lot of the time
    tx_id
    from
    terra.gov_vote
    where
    voter_address_name is null
    ),
    voting_power as (
    select
    date,
    address,
    balance
    from
    terra.daily_balances
    where
    currency = 'LUNA'
    and balance_type = 'staked'
    and balance > 0
    and address in (
    select
    distinct voter
    from
    non_val_voters
    )
    and date in (
    Run a query to Download Data