mirror of
https://github.com/FlipsideCrypto/osmosis-models.git
synced 2026-02-06 11:26:55 +00:00
An 1246 governance votes (#20)
* silver governance votes table * testing file, descriptions, and changes to incorrect descriptions in another yml file * changes to logic to handle old votes * switch to correct vote options
This commit is contained in:
parent
ed955d6036
commit
eb72fd18db
5
models/descriptions/vote_option.md
Normal file
5
models/descriptions/vote_option.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs vote_option %}
|
||||
|
||||
How the delegator voted on the proposal.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/vote_weight.md
Normal file
5
models/descriptions/vote_weight.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs vote_weight %}
|
||||
|
||||
Denotes what portion of a user's stake is put toward the voting option. If "1", 100% of the voter's voting power is put toward the selected option.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/voter.md
Normal file
5
models/descriptions/voter.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs voter %}
|
||||
|
||||
Address of the delegator that voted on the proposal.
|
||||
|
||||
{% enddocs %}
|
||||
@ -43,7 +43,7 @@ models:
|
||||
tests:
|
||||
- not_null
|
||||
- name: PROPOSAL_ID
|
||||
description: "Description goes here"
|
||||
description: "{{ doc('proposal_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: DEPOSIT_AMOUNT
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__governance_submit_proposal
|
||||
description: Records of all transactions that have occurred on Osmosis, dating back to the genesis block.
|
||||
description: Records of all proposal submissions on Osmosis, dating back to the Genesis block.
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
@ -39,7 +39,7 @@ models:
|
||||
tests:
|
||||
- not_null
|
||||
- name: PROPOSER
|
||||
description: "{{ doc('tx_code') }}"
|
||||
description: "{{ doc('proposer') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: PROPOSAL_ID
|
||||
|
||||
85
models/silver/silver__governance_votes.sql
Normal file
85
models/silver/silver__governance_votes.sql
Normal file
@ -0,0 +1,85 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = "tx_id",
|
||||
incremental_strategy = 'delete+insert',
|
||||
cluster_by = ['_ingested_at::DATE'],
|
||||
) }}
|
||||
|
||||
WITH vote_options AS (
|
||||
SELECT
|
||||
tx_id,
|
||||
msg_index,
|
||||
CASE
|
||||
WHEN attribute_value::string = 'VOTE_OPTION_YES' THEN
|
||||
1
|
||||
WHEN attribute_value::string = 'VOTE_OPTION_ABSTAIN' THEN
|
||||
2
|
||||
WHEN attribute_value::string = 'VOTE_OPTION_NO' THEN
|
||||
3
|
||||
WHEN attribute_value::string = 'VOTE_OPTION_NO_WITH_VETO' THEN
|
||||
4
|
||||
ELSE
|
||||
TRY_PARSE_JSON(attribute_value):option
|
||||
END AS vote_option,
|
||||
TRY_PARSE_JSON(attribute_value):weight :: INTEGER AS vote_weight
|
||||
FROM {{ ref('silver__msg_attributes') }}
|
||||
WHERE msg_type = 'proposal_vote'
|
||||
AND attribute_key = 'option'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _ingested_at :: DATE >= CURRENT_DATE - 2
|
||||
{% endif %}
|
||||
),
|
||||
|
||||
proposal_id AS (
|
||||
SELECT
|
||||
tx_id,
|
||||
msg_index,
|
||||
attribute_value AS proposal_id
|
||||
FROM {{ ref('silver__msg_attributes') }}
|
||||
WHERE msg_type = 'proposal_vote'
|
||||
AND attribute_key = 'proposal_id'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _ingested_at :: DATE >= CURRENT_DATE - 2
|
||||
{% endif %}
|
||||
),
|
||||
|
||||
voter AS (
|
||||
SELECT
|
||||
tx_id,
|
||||
split_part(attribute_value, '/', 0) as voter
|
||||
FROM {{ ref('silver__msg_attributes') }}
|
||||
WHERE attribute_key = 'acc_seq'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _ingested_at :: DATE >= CURRENT_DATE - 2
|
||||
{% endif %}
|
||||
)
|
||||
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp,
|
||||
blockchain,
|
||||
chain_id,
|
||||
o.tx_id,
|
||||
tx_status,
|
||||
v.voter,
|
||||
p.proposal_id,
|
||||
vote_option,
|
||||
vote_weight,
|
||||
_ingested_at
|
||||
FROM vote_options o
|
||||
|
||||
LEFT OUTER JOIN proposal_id p
|
||||
ON o.tx_id = p.tx_id AND o.msg_index = p.msg_index
|
||||
|
||||
LEFT OUTER JOIN voter v
|
||||
ON o.tx_id = v.tx_id
|
||||
|
||||
LEFT OUTER JOIN {{ ref('silver__transactions') }} t
|
||||
ON o.tx_id = t.tx_id
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE _ingested_at :: DATE >= CURRENT_DATE - 2
|
||||
{% endif %}
|
||||
60
models/silver/silver__governance_votes.yml
Normal file
60
models/silver/silver__governance_votes.yml
Normal file
@ -0,0 +1,60 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__governance_votes
|
||||
description: Records of all votes on proposals.
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- TX_ID
|
||||
- PROPOSAL_ID
|
||||
columns:
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
- name: BLOCKCHAIN
|
||||
description: "{{ doc('blockchain') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: CHAIN_ID
|
||||
description: "{{ doc('chain_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: TX_STATUS
|
||||
description: "{{ doc('tx_status') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: VOTER
|
||||
description: "{{ doc('voter') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: PROPOSAL_ID
|
||||
description: "{{ doc('proposal_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: VOTE_OPTION
|
||||
description: "{{ doc('vote_option') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: _INGESTED_AT
|
||||
description: "{{ doc('ingested_at') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
Loading…
Reference in New Issue
Block a user