Skip to content

Commit

Permalink
[#231] fix broken endpoints
Browse files Browse the repository at this point in the history
fix endpoints broken due to assumption that predefined dreps always exist, even if noone delegated to them
  • Loading branch information
jankun4 committed Feb 20, 2024
1 parent c2a6f59 commit 0fe0088
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions govtool/backend/sql/get-network-metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ with current_epoch as (
select count(*) as count
from drep_hash
), always_abstain_voting_power as (
select amount
from drep_distr
join drep_hash
select coalesce(amount, 0) as amount
from drep_hash
left join drep_distr
on drep_hash.id = drep_distr.hash_id
where drep_hash.view = 'drep_always_abstain'
order by epoch_no desc
limit 1
), always_no_confidence_voting_power as (
select amount
from drep_distr
join drep_hash
select coalesce(amount, 0) as amount
from drep_hash
left join drep_distr
on drep_hash.id = drep_distr.hash_id
where drep_hash.view = 'drep_always_no_confidence'
order by epoch_no desc
Expand Down
10 changes: 6 additions & 4 deletions govtool/backend/sql/get-voting-power.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
select drep_distr.amount
from drep_distr
join drep_hash
select coalesce(drep_distr.amount, 0) as amount
from drep_hash
left join drep_distr
on drep_hash.id = drep_distr.hash_id
where drep_hash.raw = decode(?,'hex')
where drep_hash.raw = decode(?,'hex')
order by epoch_no desc
limit 1
12 changes: 6 additions & 6 deletions govtool/backend/sql/list-proposals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ WITH LatestDrepDistr AS (
Max(end_time) as last_epoch_end_time
FROM epoch
), always_no_confidence_voting_power as (
select amount
from drep_distr
join drep_hash
select coalesce(amount, 0) as amount
from drep_hash
left join drep_distr
on drep_hash.id = drep_distr.hash_id
where drep_hash.view = 'drep_always_no_confidence'
order by epoch_no desc
limit 1
), always_abstain_voting_power as (
select amount
from drep_distr
join drep_hash
select coalesce(amount, 0) as amount
from drep_hash
left join drep_distr
on drep_hash.id = drep_distr.hash_id
where drep_hash.view = 'drep_always_abstain'
order by epoch_no desc
Expand Down
8 changes: 3 additions & 5 deletions govtool/backend/src/VVA/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ getVotingPower ::
Text ->
m Integer
getVotingPower drepId = withPool $ \conn -> do
votingPower <-
sum . map (\(SQL.Only x) -> x) <$>
liftIO
(SQL.query @_ @(SQL.Only Scientific) conn getVotingPowerSql $
SQL.Only drepId)
[SQL.Only votingPower] <-
liftIO
(SQL.query @_ @(SQL.Only Scientific) conn getVotingPowerSql $ SQL.Only drepId)
return $ floor votingPower

listDRepsSql :: SQL.Query
Expand Down

0 comments on commit 0fe0088

Please sign in to comment.