-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Synced up pool_votes endpoint with the committee/drep votes, logic/fi…
…eld wise
- Loading branch information
Showing
1 changed file
with
8 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
CREATE OR REPLACE FUNCTION grest.pool_votes(_pool_bech32 text) | ||
RETURNS TABLE ( | ||
tx_hash text, | ||
proposal_tx_hash text, | ||
cert_index integer, | ||
vote_tx_hash text, | ||
block_time integer, | ||
vote text | ||
) | ||
LANGUAGE sql STABLE | ||
AS $$ | ||
SELECT | ||
ENCODE(tx.hash, 'hex')::text AS tx_hash, | ||
ENCODE(prop_tx.hash, 'hex')::text AS proposal_tx_hash, | ||
gap.index AS cert_index, | ||
ENCODE(vote_tx.hash, 'hex')::text AS vote_tx_hash, | ||
EXTRACT(EPOCH FROM b.time)::integer AS block_time, | ||
vp.vote | ||
FROM public.pool_hash ph | ||
INNER JOIN public.voting_procedure AS vp ON ph.id = vp.pool_voter | ||
INNER JOIN public.gov_action_proposal AS gap ON vp.gov_action_proposal_id = gap.id | ||
INNER JOIN public.tx ON gap.tx_id = tx.id | ||
INNER JOIN public.block AS b ON tx.block_id = b.id | ||
INNER JOIN public.tx prop_tx ON gap.tx_id = prop_tx.id | ||
INNER JOIN public.tx vote_tx on vp.tx_id = vote_tx.id | ||
INNER JOIN public.block AS b ON vote_tx.block_id = b.id | ||
WHERE ph.view = _pool_bech32 | ||
ORDER BY | ||
block_time DESC; | ||
vote_tx.id DESC; | ||
$$; | ||
|
||
COMMENT ON FUNCTION grest.pool_votes IS 'Get all SPO votes cast for a given pool'; -- noqa: LT01 |