Skip to content

Commit

Permalink
Merge pull request #177 from makerdao/update-all-delegates
Browse files Browse the repository at this point in the history
update allDelegates query to include version
  • Loading branch information
tyler17 authored Oct 3, 2024
2 parents 741d7d6 + ba565d1 commit b746e7c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions migrations/076-new-all-delegates.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- Drop existing functions
DROP FUNCTION IF EXISTS dschief.all_delegates();
DROP FUNCTION IF EXISTS api.all_delegates();

CREATE OR REPLACE FUNCTION dschief.all_delegates()
RETURNS TABLE (
delegate character varying(66),
vote_delegate character varying(66),
delegate_version int
) AS $$
SELECT delegate, vote_delegate, delegate_version
FROM dschief.vote_delegate_created_event
$$ LANGUAGE sql STABLE STRICT;


--This query would be called by allDelegates() in the sdk
CREATE OR REPLACE FUNCTION api.all_delegates()
RETURNS TABLE (
delegate character varying(66),
vote_delegate character varying(66),
delegate_version int,
block_timestamp TIMESTAMP WITH TIME ZONE
) AS $$
SELECT delegate, vote_delegate, delegate_version, b.timestamp
FROM dschief.vote_delegate_created_event d
LEFT JOIN vulcan2x.block b
ON d.block_id = b.id;
$$ LANGUAGE sql STABLE STRICT;

0 comments on commit b746e7c

Please sign in to comment.