-
Notifications
You must be signed in to change notification settings - Fork 10
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 #2716 from IntersectMBO/staging
hotfix: handle type mismatch between haskell and sql result
- Loading branch information
Showing
4 changed files
with
51 additions
and
16 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
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,13 +1,46 @@ | ||
WITH RewardRest AS ( | ||
SELECT | ||
SUM(amount) AS amount, | ||
addr_id | ||
FROM | ||
reward_rest | ||
GROUP BY | ||
addr_id | ||
), | ||
Reward AS ( | ||
SELECT | ||
SUM(amount) AS amount, | ||
addr_id | ||
FROM | ||
reward | ||
GROUP BY | ||
addr_id | ||
), | ||
Balance AS ( | ||
SELECT | ||
COALESCE(SUM(uv.value), 0) AS amount, | ||
sa.id AS addr_id, | ||
encode(sa.hash_raw, 'hex') AS addr_raw | ||
FROM | ||
stake_address sa | ||
JOIN utxo_view uv ON uv.stake_address_id = sa.id | ||
GROUP BY | ||
addr_id, | ||
addr_raw | ||
) | ||
SELECT | ||
COALESCE(SUM(tx_out.value), 0) AS voting_power, | ||
stake_address.id as addr_id | ||
(COALESCE(rr.amount, 0) + COALESCE(r.amount, 0) + COALESCE(b.amount, 0)) AS total_balance, | ||
b.addr_raw::text AS stake_address | ||
FROM | ||
stake_address | ||
JOIN | ||
tx_out on tx_out.stake_address_id = stake_address.id | ||
Balance b | ||
LEFT JOIN | ||
tx_in ON tx_in.tx_out_id = tx_out.id AND tx_in.tx_out_index = tx_out.index | ||
RewardRest rr ON rr.addr_id = b.addr_id | ||
LEFT JOIN | ||
Reward r ON r.addr_id = rr.addr_id | ||
WHERE | ||
stake_address.hash_raw = decode(?, 'hex') AND tx_in.id IS NULL | ||
b.addr_id = (SELECT id FROM stake_address WHERE hash_raw = decode(?, 'hex')) | ||
GROUP BY | ||
stake_address.id; | ||
b.addr_raw, | ||
rr.amount, | ||
r.amount, | ||
b.amount |
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