Skip to content

Commit

Permalink
Synced up pool_votes endpoint with the committee/drep votes, logic/fi…
Browse files Browse the repository at this point in the history
…eld wise
  • Loading branch information
cardadad committed Aug 2, 2024
1 parent 96ceea9 commit 7b13500
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions files/grest/rpc/pool/pool_votes.sql
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

0 comments on commit 7b13500

Please sign in to comment.