Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#826] fix drep/list sql #828

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading