angealgovernance__n_gov_votes
    Updated 2023-01-17
    with votes as(
    -- votes on core protocol stuff
    select
    voter AS address,
    count(distinct proposal_id) as n_gov_votes
    from terra.gov_vote
    where block_timestamp > current_date - interval '90 days'
    group by address
    union
    -- votes for protocols based on the gov contracts
    select
    --event_attributes:contract_address::string as staking_contract,
    event_attributes:voter::string as address,
    count( distinct tx_id ) as n_gov_votes
    from terra.msg_events
    where event_type = 'from_contract'
    and event_attributes:action = 'cast_vote'
    and block_timestamp > current_date - 90
    group by 1
    )
    select
    v.address,
    sum(v.n_gov_votes) as n_governance_votes
    from
    votes v
    group by 1;


    Run a query to Download Data