Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional abstain vote count fields added #303

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions files/grest/rpc/02_indexes/13_3_00.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
CREATE INDEX IF NOT EXISTS pool_stat_pool_hash_id ON pool_stat(pool_hash_id);
CREATE INDEX IF NOT EXISTS pool_stat_epoch_no ON pool_stat(epoch_no);
-- CREATE INDEX IF NOT EXISTS idx_drep_hash_view ON drep_hash (view);
CREATE INDEX IF NOT EXISTS idx_drep_hash_raw ON drep_hash (raw);
CREATE INDEX IF NOT EXISTS idx_reward_rest_addr_id ON reward_rest (addr_id);
CREATE INDEX IF NOT EXISTS idx_reward_rest_spendable_epoch ON reward_rest (spendable_epoch);
3 changes: 3 additions & 0 deletions files/grest/rpc/02_indexes/13_5_0_2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DROP INDEX IF EXISTS idx_stake_address_view;
CREATE INDEX IF NOT EXISTS idx_stake_address_hash_raw ON stake_address (hash_raw);
CREATE INDEX IF NOT EXISTS idx_drep_hash_raw ON drep_hash (raw);
11 changes: 9 additions & 2 deletions files/grest/rpc/governance/proposal_voting_summary.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

CREATE OR REPLACE FUNCTION grest.proposal_voting_summary(_proposal_id text)
RETURNS TABLE (
proposal_type text,
Expand All @@ -8,16 +9,19 @@ RETURNS TABLE (
drep_no_votes_cast integer,
drep_no_vote_power lovelace,
drep_no_pct numeric,
drep_abstain_votes_cast integer,
pool_yes_votes_cast integer,
pool_yes_vote_power lovelace,
pool_yes_pct numeric,
pool_no_votes_cast integer,
pool_no_vote_power lovelace,
pool_no_pct numeric,
pool_abstain_votes_cast integer,
committee_yes_votes_cast integer,
committee_yes_pct numeric,
committee_no_votes_cast integer,
committee_no_pct numeric
committee_no_pct numeric,
committee_abstain_votes_cast integer
)
LANGUAGE plpgsql
AS $$
Expand Down Expand Up @@ -169,6 +173,7 @@ BEGIN
y.drep_no_votes_cast::integer,
(y.drep_non_abstain_total - y.drep_yes_vote_power)::lovelace AS drep_no_vote_power,
ROUND((y.drep_non_abstain_total - y.drep_yes_vote_power) * 100 / y.drep_non_abstain_total, 2) AS drep_no_pct,
(SELECT COALESCE(SUM(active_drep_votes_cast), 0)::integer FROM active_prop_drep_votes WHERE vote = 'Abstain') AS drep_abstain_votes_cast,
(CASE
WHEN y.proposal_type IN ('ParameterChange', 'TreasuryWithdrawals', 'NewConstitution') THEN 0
ELSE y.pool_yes_votes_cast
Expand All @@ -193,6 +198,7 @@ BEGIN
WHEN y.proposal_type IN ('ParameterChange', 'TreasuryWithdrawals', 'NewConstitution') THEN 0
ELSE ROUND((y.pool_non_abstain_total - y.pool_yes_vote_power) * 100 / y.pool_non_abstain_total, 2)
END) AS pool_no_pct,
(SELECT COALESCE(SUM(pool_votes_cast), 0)::integer FROM active_prop_pool_votes WHERE vote = 'Abstain') AS pool_abstain_votes_cast,
y.committee_yes_votes_cast::integer,
(CASE
WHEN y.proposal_type IN ('NoConfidence', 'NewCommittee') THEN 0
Expand All @@ -205,7 +211,8 @@ BEGIN
(CASE
WHEN y.proposal_type IN ('NoConfidence', 'NewCommittee') THEN 0
ELSE ROUND((committee_non_abstain_total - y.committee_yes_votes_cast) * 100 / y.committee_non_abstain_total, 2)
END) AS committee_no_pct
END) AS committee_no_pct,
(SELECT COALESCE(SUM(committee_votes_cast), 0)::integer FROM committee_votes WHERE vote = 'Abstain') AS committee_abstain_votes_cast
FROM
(
SELECT
Expand Down
4 changes: 2 additions & 2 deletions files/grest/rpc/governance/voter_proposal_list.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ BEGIN
gap.type,
gap.description,
gap.deposit::text,
grest.cip5_hex_to_stake_addr(sa.hash_raw)::text,
grest.cip5_hex_to_stake_addr(sa.hash_raw)::varchar,
b.epoch_no,
gap.ratified_epoch,
gap.enacted_epoch,
Expand All @@ -81,7 +81,7 @@ BEGIN
ELSE
JSONB_BUILD_OBJECT(
'stake_address', (
SELECT grest.cip5_hex_to_stake_addr(sa2.hash_raw)::text
SELECT grest.cip5_hex_to_stake_addr(sa2.hash_raw)::varchar
FROM stake_address AS sa2
WHERE sa2.id = tw.stake_address_id
),
Expand Down
14 changes: 12 additions & 2 deletions specs/results/koiosapi-guild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
license:
name: Creative Commons Attribution 4.0 International
url: https://github.com/cardano-community/koios-artifacts/blob/main/LICENSE
version: v1.2.0
version: v1.2.1
description: |
Koios is best described as a Decentralized and Elastic RESTful query layer for exploring data on Cardano blockchain to consume within applications/wallets/explorers/etc. This page not only provides an OpenAPI Spec for live implementation, but also ability to execute live demo from client browser against each endpoint with pre-filled examples.

Expand Down Expand Up @@ -3061,7 +3061,7 @@ components:
example: "31235800000"
active_stake_pct:
type:
- string
- number
- 'null'
description: Active stake for the pool, expressed as a percentage of total active stake on network
example: 13.512182543475783
Expand Down Expand Up @@ -5494,6 +5494,10 @@ components:
type: number
description: Percentage of 'no' votes from dreps
example: 39.28
drep_abstain_votes_cast:
type: number
description: Percentage of 'abstain' votes from dreps
example: 5
pool_yes_votes_cast:
type: number
description: Number of 'yes' votes casted by pools
Expand All @@ -5518,6 +5522,9 @@ components:
type: number
description: Percentage of 'no' votes from pools
example: 0
pool_abstain_votes_cast:
type: number
description: Percentage of 'abstain' votes from pools
committee_yes_votes_cast:
type: number
description: Number of 'yes' votes casted by committee
Expand All @@ -5534,6 +5541,9 @@ components:
type: number
description: Percentage of 'no' votes from committee
example: 28.57
committee_abstain_votes_cast:
type: number
description: Percentage of 'abstain' votes from committee
proposal_votes:
type: array
description: List of all votes cast on specified governance action
Expand Down
14 changes: 12 additions & 2 deletions specs/results/koiosapi-mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
license:
name: Creative Commons Attribution 4.0 International
url: https://github.com/cardano-community/koios-artifacts/blob/main/LICENSE
version: v1.2.0
version: v1.2.1
description: |
Koios is best described as a Decentralized and Elastic RESTful query layer for exploring data on Cardano blockchain to consume within applications/wallets/explorers/etc. This page not only provides an OpenAPI Spec for live implementation, but also ability to execute live demo from client browser against each endpoint with pre-filled examples.

Expand Down Expand Up @@ -3061,7 +3061,7 @@ components:
example: "31235800000"
active_stake_pct:
type:
- string
- number
- 'null'
description: Active stake for the pool, expressed as a percentage of total active stake on network
example: 13.512182543475783
Expand Down Expand Up @@ -5494,6 +5494,10 @@ components:
type: number
description: Percentage of 'no' votes from dreps
example: 39.28
drep_abstain_votes_cast:
type: number
description: Percentage of 'abstain' votes from dreps
example: 5
pool_yes_votes_cast:
type: number
description: Number of 'yes' votes casted by pools
Expand All @@ -5518,6 +5522,9 @@ components:
type: number
description: Percentage of 'no' votes from pools
example: 0
pool_abstain_votes_cast:
type: number
description: Percentage of 'abstain' votes from pools
committee_yes_votes_cast:
type: number
description: Number of 'yes' votes casted by committee
Expand All @@ -5534,6 +5541,9 @@ components:
type: number
description: Percentage of 'no' votes from committee
example: 28.57
committee_abstain_votes_cast:
type: number
description: Percentage of 'abstain' votes from committee
proposal_votes:
type: array
description: List of all votes cast on specified governance action
Expand Down
14 changes: 12 additions & 2 deletions specs/results/koiosapi-preprod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
license:
name: Creative Commons Attribution 4.0 International
url: https://github.com/cardano-community/koios-artifacts/blob/main/LICENSE
version: v1.2.0
version: v1.2.1
description: |
Koios is best described as a Decentralized and Elastic RESTful query layer for exploring data on Cardano blockchain to consume within applications/wallets/explorers/etc. This page not only provides an OpenAPI Spec for live implementation, but also ability to execute live demo from client browser against each endpoint with pre-filled examples.

Expand Down Expand Up @@ -3061,7 +3061,7 @@ components:
example: "31235800000"
active_stake_pct:
type:
- string
- number
- 'null'
description: Active stake for the pool, expressed as a percentage of total active stake on network
example: 13.512182543475783
Expand Down Expand Up @@ -5494,6 +5494,10 @@ components:
type: number
description: Percentage of 'no' votes from dreps
example: 39.28
drep_abstain_votes_cast:
type: number
description: Percentage of 'abstain' votes from dreps
example: 5
pool_yes_votes_cast:
type: number
description: Number of 'yes' votes casted by pools
Expand All @@ -5518,6 +5522,9 @@ components:
type: number
description: Percentage of 'no' votes from pools
example: 0
pool_abstain_votes_cast:
type: number
description: Percentage of 'abstain' votes from pools
committee_yes_votes_cast:
type: number
description: Number of 'yes' votes casted by committee
Expand All @@ -5534,6 +5541,9 @@ components:
type: number
description: Percentage of 'no' votes from committee
example: 28.57
committee_abstain_votes_cast:
type: number
description: Percentage of 'abstain' votes from committee
proposal_votes:
type: array
description: List of all votes cast on specified governance action
Expand Down
14 changes: 12 additions & 2 deletions specs/results/koiosapi-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
license:
name: Creative Commons Attribution 4.0 International
url: https://github.com/cardano-community/koios-artifacts/blob/main/LICENSE
version: v1.2.0
version: v1.2.1
description: |
Koios is best described as a Decentralized and Elastic RESTful query layer for exploring data on Cardano blockchain to consume within applications/wallets/explorers/etc. This page not only provides an OpenAPI Spec for live implementation, but also ability to execute live demo from client browser against each endpoint with pre-filled examples.

Expand Down Expand Up @@ -3061,7 +3061,7 @@ components:
example: "31235800000"
active_stake_pct:
type:
- string
- number
- 'null'
description: Active stake for the pool, expressed as a percentage of total active stake on network
example: 13.512182543475783
Expand Down Expand Up @@ -5494,6 +5494,10 @@ components:
type: number
description: Percentage of 'no' votes from dreps
example: 39.28
drep_abstain_votes_cast:
type: number
description: Percentage of 'abstain' votes from dreps
example: 5
pool_yes_votes_cast:
type: number
description: Number of 'yes' votes casted by pools
Expand All @@ -5518,6 +5522,9 @@ components:
type: number
description: Percentage of 'no' votes from pools
example: 0
pool_abstain_votes_cast:
type: number
description: Percentage of 'abstain' votes from pools
committee_yes_votes_cast:
type: number
description: Number of 'yes' votes casted by committee
Expand All @@ -5534,6 +5541,9 @@ components:
type: number
description: Percentage of 'no' votes from committee
example: 28.57
committee_abstain_votes_cast:
type: number
description: Percentage of 'abstain' votes from committee
proposal_votes:
type: array
description: List of all votes cast on specified governance action
Expand Down
2 changes: 1 addition & 1 deletion specs/templates/1-api-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ info:
license:
name: Creative Commons Attribution 4.0 International
url: https://github.com/cardano-community/koios-artifacts/blob/main/LICENSE
version: v1.2.0
version: v1.2.1
description: |
Koios is best described as a Decentralized and Elastic RESTful query layer for exploring data on Cardano blockchain to consume within applications/wallets/explorers/etc. This page not only provides an OpenAPI Spec for live implementation, but also ability to execute live demo from client browser against each endpoint with pre-filled examples.

Expand Down
12 changes: 11 additions & 1 deletion specs/templates/4-api-schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ schemas:
example: "31235800000"
active_stake_pct:
type:
- string
- number
- 'null'
description: Active stake for the pool, expressed as a percentage of total active stake on network
example: 13.512182543475783
Expand Down Expand Up @@ -2659,6 +2659,10 @@ schemas:
type: number
description: Percentage of 'no' votes from dreps
example: 39.28
drep_abstain_votes_cast:
type: number
description: Percentage of 'abstain' votes from dreps
example: 5
pool_yes_votes_cast:
type: number
description: Number of 'yes' votes casted by pools
Expand All @@ -2683,6 +2687,9 @@ schemas:
type: number
description: Percentage of 'no' votes from pools
example: 0
pool_abstain_votes_cast:
type: number
description: Percentage of 'abstain' votes from pools
committee_yes_votes_cast:
type: number
description: Number of 'yes' votes casted by committee
Expand All @@ -2699,6 +2706,9 @@ schemas:
type: number
description: Percentage of 'no' votes from committee
example: 28.57
committee_abstain_votes_cast:
type: number
description: Percentage of 'abstain' votes from committee
proposal_votes:
type: array
description: List of all votes cast on specified governance action
Expand Down
Loading