File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed
Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -123,18 +123,23 @@ PoolVotes AS (
123123 rpv .gov_action_proposal_id , ps .epoch_no
124124),
125125RankedDRepVotes AS (
126- SELECT
127- * ,
128- ROW_NUMBER() OVER (PARTITION BY vp .drep_voter ORDER BY vp .tx_id DESC ) AS rn
129- FROM
126+ SELECT DISTINCT ON (vp .drep_voter , vp .gov_action_proposal_id )
127+ *
128+ FROM
130129 voting_procedure vp
130+ ORDER BY
131+ vp .drep_voter ,
132+ vp .gov_action_proposal_id ,
133+ vp .tx_id DESC
131134),
132135RankedDRepRegistration AS (
133- SELECT
134- * ,
135- ROW_NUMBER() OVER (PARTITION BY dr .drep_hash_id ORDER BY dr .tx_id DESC ) AS rn
136- FROM
136+ SELECT DISTINCT ON (dr .drep_hash_id )
137+ *
138+ FROM
137139 drep_registration dr
140+ ORDER BY
141+ dr .drep_hash_id ,
142+ dr .tx_id DESC
138143),
139144CommitteeVotes AS (
140145 SELECT
283288 LEFT JOIN cost_model AS cost_model ON proposal_params .cost_model_id = cost_model .id
284289 LEFT JOIN PoolVotes ps ON gov_action_proposal .id = ps .gov_action_proposal_id
285290 LEFT JOIN CommitteeVotes cv ON gov_action_proposal .id = cv .gov_action_proposal_id
286- LEFT JOIN RankedDRepVotes rdv ON rdv .gov_action_proposal_id = gov_action_proposal .id AND rdv . rn = 1
287- LEFT JOIN RankedDRepRegistration rdr ON rdr .drep_hash_id = rdv .drep_voter AND COALESCE(rdr .deposit , 0 ) >= 0 AND rdr . rn = 1
291+ LEFT JOIN RankedDRepVotes rdv ON rdv .gov_action_proposal_id = gov_action_proposal .id
292+ LEFT JOIN RankedDRepRegistration rdr ON rdr .drep_hash_id = rdv .drep_voter AND COALESCE(rdr .deposit , 0 ) >= 0
288293 LEFT JOIN LatestDrepDistr ldd_drep ON ldd_drep .hash_id = rdr .drep_hash_id
289294 AND ldd_drep .epoch_no = latest_epoch .no
290295 LEFT JOIN gov_action_proposal AS prev_gov_action ON gov_action_proposal .prev_gov_action_proposal = prev_gov_action .id
You can’t perform that action at this time.
0 commit comments