|
|
@ -55,7 +55,31 @@ class BalancePostgresDAO @Inject() (fieldOrderingSQLInterpreter: FieldOrderingSQ |
|
|
|
).as(parseBalance.*).flatten |
|
|
|
} |
|
|
|
|
|
|
|
def countRichest(implicit conn: Connection): Count = { |
|
|
|
def getNonZeroBalances( |
|
|
|
query: PaginatedQuery, |
|
|
|
ordering: FieldOrdering[BalanceField])( |
|
|
|
implicit conn: Connection): List[Balance] = { |
|
|
|
|
|
|
|
val orderBy = fieldOrderingSQLInterpreter.toOrderByClause(ordering) |
|
|
|
SQL( |
|
|
|
s""" |
|
|
|
|SELECT address, received, spent |
|
|
|
|FROM balances |
|
|
|
|WHERE address NOT IN ( |
|
|
|
| SELECT address |
|
|
|
| FROM hidden_addresses) AND |
|
|
|
| (received - spent) > 0 |
|
|
|
|$orderBy |
|
|
|
|OFFSET {offset} |
|
|
|
|LIMIT {limit} |
|
|
|
""".stripMargin |
|
|
|
).on( |
|
|
|
'offset -> query.offset.int, |
|
|
|
'limit -> query.limit.int |
|
|
|
).as(parseBalance.*).flatten |
|
|
|
} |
|
|
|
|
|
|
|
def count(implicit conn: Connection): Count = { |
|
|
|
val result = SQL( |
|
|
|
""" |
|
|
|
|SELECT COUNT(*) |
|
|
@ -69,4 +93,19 @@ class BalancePostgresDAO @Inject() (fieldOrderingSQLInterpreter: FieldOrderingSQ |
|
|
|
|
|
|
|
Count(result) |
|
|
|
} |
|
|
|
|
|
|
|
def countNonZeroBalances(implicit conn: Connection): Count = { |
|
|
|
val result = SQL( |
|
|
|
""" |
|
|
|
|SELECT COUNT(*) |
|
|
|
|FROM balances |
|
|
|
|WHERE address NOT IN ( |
|
|
|
| SELECT address |
|
|
|
| FROM hidden_addresses) AND |
|
|
|
| (received - spent) > 0 |
|
|
|
""".stripMargin |
|
|
|
).as(SqlParser.scalar[Int].single) |
|
|
|
|
|
|
|
Count(result) |
|
|
|
} |
|
|
|
} |
|
|
|