Skip to content

Commit

Permalink
Revert "Minor SQL improvements."
Browse files Browse the repository at this point in the history
This reverts commit 8f045cc
  • Loading branch information
oskin1 committed Feb 27, 2021
1 parent f8b83c5 commit 25237ee
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ object OutputQuerySet extends QuerySet {
maxHeight: Int
)(implicit lh: LogHandler): Query0[Long] =
sql"""
|select sum(o.value) from node_outputs o
|select coalesce(cast(sum(o.value) as bigint), 0)
|from node_outputs o
|left join node_inputs i on o.box_id = i.box_id and i.main_chain = true
|left join node_transactions tx on tx.id = o.tx_id
|where tx.main_chain = true
| and tx.inclusion_height <= $maxHeight
Expand All @@ -137,7 +139,7 @@ object OutputQuerySet extends QuerySet {
maxHeight: Int
)(implicit lh: LogHandler): Query0[Long] =
sql"""
|select sum(o.value) from node_outputs o
|select coalesce(cast(sum(o.value) as bigint), 0) from node_outputs o
|left join node_inputs i on o.box_id = i.box_id and i.main_chain = true
|left join node_transactions tx on tx.id = o.tx_id
|where tx.main_chain = true
Expand All @@ -160,7 +162,7 @@ object OutputQuerySet extends QuerySet {

def balanceStatsMain(offset: Int, limit: Int)(implicit lh: LogHandler): Query0[(Address, Long)] =
sql"""
|select o.address, sum(o.value) as balance from node_outputs o
|select o.address, coalesce(cast(sum(o.value) as bigint), 0) as balance from node_outputs o
|left join node_inputs i on o.box_id = i.box_id and i.main_chain = true
|left join node_transactions tx on tx.id = o.tx_id
|where o.main_chain = true and i.box_id is null
Expand Down

0 comments on commit 25237ee

Please sign in to comment.