added support for --order_by=none

This commit is contained in:
Lex Berezhny 2020-03-21 18:16:25 -04:00
parent 15091052be
commit 6a58148a89
2 changed files with 5 additions and 3 deletions

View file

@ -4164,7 +4164,7 @@ class Daemon(metaclass=JSONRPCServerType):
] ]
[--exclude_internal_transfers] [--exclude_internal_transfers]
[--wallet_id=<wallet_id>] [--page=<page>] [--page_size=<page_size>] [--wallet_id=<wallet_id>] [--page=<page>] [--page_size=<page_size>]
[--resolve] [--no_totals] [--resolve] [--order_by=<order_by>][--no_totals]
Options: Options:
--type=<type> : (str or list) claim type: stream, channel, support, --type=<type> : (str or list) claim type: stream, channel, support,
@ -4190,7 +4190,7 @@ class Daemon(metaclass=JSONRPCServerType):
--page=<page> : (int) page to return during paginating --page=<page> : (int) page to return during paginating
--page_size=<page_size> : (int) number of items on page during pagination --page_size=<page_size> : (int) number of items on page during pagination
--resolve : (bool) resolves each claim to provide additional metadata --resolve : (bool) resolves each claim to provide additional metadata
--order_by=<order_by> : (str) field to order by: 'name', 'height', 'amount' --order_by=<order_by> : (str) field to order by: 'name', 'height', 'amount' and 'none'
--no_totals : (bool) do not calculate the total number of pages and items in result set --no_totals : (bool) do not calculate the total number of pages and items in result set
(significant performance boost) (significant performance boost)
@ -4213,7 +4213,7 @@ class Daemon(metaclass=JSONRPCServerType):
if order_by is not None: if order_by is not None:
if order_by == 'name': if order_by == 'name':
constraints['order_by'] = 'txo.claim_name' constraints['order_by'] = 'txo.claim_name'
elif order_by in ('height', 'amount'): elif order_by in ('height', 'amount', 'none'):
constraints['order_by'] = order_by constraints['order_by'] = order_by
else: else:
raise ValueError(f"'{order_by}' is not a valid --order_by value.") raise ValueError(f"'{order_by}' is not a valid --order_by value.")

View file

@ -787,6 +787,8 @@ class Database(SQLiteMixin):
constraints['order_by'] = [ constraints['order_by'] = [
"tx.height=0 DESC", "tx.height DESC", "tx.position DESC", "txo.position" "tx.height=0 DESC", "tx.height DESC", "tx.position DESC", "txo.position"
] ]
elif constraints.get('order_by', None) == 'none':
del constraints['order_by']
rows = await self.select_txos(', '.join(select_columns), read_only=read_only, **constraints) rows = await self.select_txos(', '.join(select_columns), read_only=read_only, **constraints)