-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #357 from IntersectMBO/prestaging
sync staging with recent test
- Loading branch information
Showing
79 changed files
with
1,524 additions
and
587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,86 @@ | ||
WITH DRepId AS ( | ||
SELECT decode(?, 'hex') as raw | ||
), IsRegistered AS ( | ||
SELECT (deposit>0) as value, | ||
deposit as deposit | ||
FROM drep_registration | ||
JOIN drep_hash | ||
ON drep_hash.id = drep_registration.drep_hash_id | ||
CROSS JOIN DRepId | ||
WHERE drep_hash.raw = DRepId.raw | ||
and deposit is not null | ||
ORDER BY drep_registration.tx_id DESC | ||
SELECT | ||
decode(?, 'hex') AS raw | ||
), | ||
LatestRegistrationEntry AS ( | ||
SELECT | ||
drep_registration.voting_anchor_id AS voting_anchor_id, | ||
deposit AS deposit | ||
FROM | ||
drep_registration | ||
CROSS JOIN DrepId | ||
JOIN drep_hash ON drep_hash.id = drep_registration.drep_hash_id | ||
WHERE | ||
drep_hash.raw = DRepId.raw | ||
ORDER BY | ||
drep_registration.tx_id DESC | ||
LIMIT 1 | ||
), WasRegistered AS ( | ||
select (EXISTS ( | ||
SELECT * | ||
FROM drep_registration | ||
JOIN drep_hash | ||
ON drep_hash.id = drep_registration.drep_hash_id | ||
CROSS JOIN DRepId | ||
WHERE drep_hash.raw = DRepId.raw | ||
and drep_registration.deposit > 0 | ||
)) as value | ||
), | ||
IsRegisteredAsDRep AS ( | ||
SELECT | ||
(LatestRegistrationEntry.deposit is null or LatestRegistrationEntry.deposit > 0) | ||
AND LatestRegistrationEntry.voting_anchor_id IS NOT NULL AS value | ||
FROM | ||
LatestRegistrationEntry | ||
), | ||
IsRegisteredAsSoleVoter AS ( | ||
SELECT | ||
(LatestRegistrationEntry.deposit is null or LatestRegistrationEntry.deposit > 0) | ||
AND LatestRegistrationEntry.voting_anchor_id IS NULL AS value | ||
FROM | ||
LatestRegistrationEntry | ||
), | ||
CurrentDeposit AS ( | ||
SELECT | ||
GREATEST(drep_registration.deposit, 0) AS value | ||
FROM | ||
drep_registration | ||
join drep_hash | ||
on drep_hash.id = drep_registration.drep_hash_id | ||
cross join DRepId | ||
|
||
WHERE | ||
drep_registration.deposit IS NOT NULL | ||
and drep_hash.raw = DRepId.raw | ||
ORDER BY | ||
drep_registration.tx_id DESC | ||
LIMIT 1 | ||
), | ||
WasRegisteredAsDRep AS ( | ||
SELECT | ||
(EXISTS ( | ||
SELECT | ||
* | ||
FROM | ||
drep_registration | ||
JOIN drep_hash ON drep_hash.id = drep_registration.drep_hash_id | ||
CROSS JOIN DRepId | ||
WHERE | ||
drep_hash.raw = DRepId.raw | ||
AND drep_registration.voting_anchor_id IS NOT NULL)) AS value | ||
), | ||
WasRegisteredAsSoleVoter AS ( | ||
SELECT | ||
(EXISTS ( | ||
SELECT | ||
* | ||
FROM | ||
drep_registration | ||
JOIN drep_hash ON drep_hash.id = drep_registration.drep_hash_id | ||
CROSS JOIN DRepId | ||
WHERE | ||
drep_hash.raw = DRepId.raw | ||
AND drep_registration.voting_anchor_id IS NULL)) AS value | ||
) | ||
SELECT IsRegistered.value, WasRegistered.value, IsRegistered.deposit | ||
FROM WasRegistered | ||
LEFT JOIN IsRegistered | ||
ON 1=1 | ||
SELECT | ||
IsRegisteredAsDRep.value, | ||
WasRegisteredAsDRep.value, | ||
IsRegisteredAsSoleVoter.value, | ||
WasRegisteredAsSoleVoter.value, | ||
CurrentDeposit.value | ||
FROM | ||
IsRegisteredAsDRep | ||
CROSS JOIN IsRegisteredAsSoleVoter | ||
CROSS JOIN WasRegisteredAsDRep | ||
CROSS JOIN WasRegisteredAsSoleVoter | ||
CROSS JOIN CurrentDeposit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.