Afonso_DiazUntitled Query
    Updated 2023-01-23
    with t as (
    select
    voter,
    min(block_timestamp)::date as min_date
    from terra.core.fact_governance_votes
    where tx_succeeded = 1
    group by 1
    ),

    t2 as (
    select
    proposal_id,
    min(block_timestamp)::date as min_date
    from terra.core.fact_governance_votes
    where tx_succeeded = 1
    group by 1
    )

    select
    date_trunc('week', a.block_timestamp::date) as day,
    count(distinct tx_id) as votes_count,
    count(distinct t2.proposal_id) as new_proposals_count,
    count(distinct a.proposal_id) as active_proposals_count,
    count(distinct t.voter) as new_voters_count,
    count(distinct a.voter) as voters_count,
    sum(votes_count) over (order by day) as cumulative_votes_count,
    sum(new_proposals_count) over (order by day) as cumulative_new_proposals_count,
    sum(active_proposals_count) over (order by day) as cumulative_active_proposals_count,
    sum(new_voters_count) over (order by day) as cumulative_new_voters_count,
    sum(voters_count) over (order by day) as cumulative_voters_count
    from terra.core.fact_governance_votes a
    left join t on a.block_timestamp::date = t.min_date
    left join t2 on a.block_timestamp::date = t2.min_date
    group by 1
    order by 1
    Run a query to Download Data