Skip to content

Commit

Permalink
[#1951] add workaround for multiple rows for one drep view in drep_ha…
Browse files Browse the repository at this point in the history
…sh table
  • Loading branch information
j-dyczka committed Oct 21, 2024
1 parent 7ba23cc commit 5eac3f2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
8 changes: 7 additions & 1 deletion govtool/backend/sql/get-current-delegation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ select
else encode(drep_hash.raw,'hex')
end as drep_raw,
drep_hash.view as drep_view,
drep_hash.has_script,
EXISTS (
SELECT dh.has_script
FROM drep_hash as dh
WHERE drep_hash.raw = dh.raw
AND dh.has_script = true
LIMIT 1
) AS has_script,
encode(tx.hash, 'hex')
from delegation_vote
join tx on tx.id = delegation_vote.tx_id
Expand Down
21 changes: 12 additions & 9 deletions govtool/backend/sql/get-drep-info.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@ LatestRegistrationEntry AS (
LIMIT 1
),
IsScriptHash AS (
SELECT
drep_hash.has_script AS value
FROM
drep_hash
CROSS JOIN DRepId
WHERE
drep_hash.raw = DRepId.raw
),
SELECT EXISTS(
SELECT
drep_hash.has_script
FROM
drep_hash
CROSS JOIN DRepId
WHERE
drep_hash.raw = DRepId.raw
AND
drep_hash.has_script = true
) AS has_script),
IsRegisteredAsDRep AS (
SELECT
(LatestRegistrationEntry.deposit IS NULL
Expand Down Expand Up @@ -174,7 +177,7 @@ SoleVoterRetire AS (
LIMIT 1
)
SELECT
IsScriptHash.value,
IsScriptHash.has_script,
IsRegisteredAsDRep.value,
WasRegisteredAsDRep.value,
IsRegisteredAsSoleVoter.value,
Expand Down

0 comments on commit 5eac3f2

Please sign in to comment.