Skip to content

Commit

Permalink
Merge pull request #828 from IntersectMBO/826-no-dreps-found-in-dreplist
Browse files Browse the repository at this point in the history
[#826] fix drep/list sql
  • Loading branch information
MSzalowski committed Apr 22, 2024
2 parents c6d5469 + 7a00b94 commit 84cab12
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ changes.

### Fixed

- drep/list sql fix (now the latest tx date is correct) [Issue 826](https://github.com/IntersectMBO/govtool/issues/826)
- drep/info no longer returns null values [Issue 720](https://github.com/IntersectMBO/govtool/issues/720)
- drep/getVotes no longer returns 500 [Issue 685](https://github.com/IntersectMBO/govtool/issues/685)
- drep/info no longer returns 500 [Issue 676](https://github.com/IntersectMBO/govtool/issues/676)
Expand Down
10 changes: 5 additions & 5 deletions govtool/backend/sql/list-dreps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ FROM
LEFT JOIN voting_procedure AS voting_procedure ON voting_procedure.drep_voter = dh.id
LEFT JOIN tx AS tx ON tx.id = voting_procedure.tx_id
LEFT JOIN block AS block ON block.id = tx.block_id
JOIN (
LEFT JOIN (
SELECT
block.time,
dr.drep_hash_id,
Expand All @@ -79,18 +79,18 @@ FROM
JOIN tx ON tx.id = dr.tx_id
JOIN block ON block.id = tx.block_id
WHERE
NOT (dr.deposit > 0)) AS newestRegister ON newestRegister.drep_hash_id = dh.id
NOT (dr.deposit < 0)) AS newestRegister ON newestRegister.drep_hash_id = dh.id
AND newestRegister.rn = 1
JOIN (
LEFT JOIN (
SELECT
dr.tx_id,
dr.drep_hash_id,
ROW_NUMBER() OVER (PARTITION BY dr.drep_hash_id ORDER BY dr.tx_id ASC) AS rn
FROM
drep_registration dr) AS dr_first_register ON dr_first_register.drep_hash_id = dh.id
AND dr_first_register.rn = 1
JOIN tx AS tx_first_register ON tx_first_register.id = dr_first_register.tx_id
JOIN block AS block_first_register ON block_first_register.id = tx_first_register.block_id
LEFT JOIN tx AS tx_first_register ON tx_first_register.id = dr_first_register.tx_id
LEFT JOIN block AS block_first_register ON block_first_register.id = tx_first_register.block_id
GROUP BY
dh.raw,
second_to_newest_drep_registration.voting_anchor_id,
Expand Down

0 comments on commit 84cab12

Please sign in to comment.