Paginates only if either --page or --page_size are provided
This commit is contained in:
parent
b30dc39e37
commit
766dcff6c6
2 changed files with 11 additions and 10 deletions
|
@ -1774,7 +1774,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
[--claim_name=<claim_name>] [--blobs_in_stream=<blobs_in_stream>]
|
[--claim_name=<claim_name>] [--blobs_in_stream=<blobs_in_stream>]
|
||||||
[--blobs_remaining=<blobs_remaining>] [--sort=<sort_by>]
|
[--blobs_remaining=<blobs_remaining>] [--sort=<sort_by>]
|
||||||
[--comparison=<comparison>] [--full_status=<full_status>] [--reverse]
|
[--comparison=<comparison>] [--full_status=<full_status>] [--reverse]
|
||||||
[(--page=<page> --page_size=<page_size>)]
|
[--page=<page> --page_size=<page_size>]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--sd_hash=<sd_hash> : (str) get file with matching sd hash
|
--sd_hash=<sd_hash> : (str) get file with matching sd hash
|
||||||
|
@ -1793,8 +1793,8 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
--blobs_remaining=<blobs_remaining> : (int) amount of remaining blobs to download
|
--blobs_remaining=<blobs_remaining> : (int) amount of remaining blobs to download
|
||||||
--sort=<sort_by> : (str) field to sort by (one of the above filter fields)
|
--sort=<sort_by> : (str) field to sort by (one of the above filter fields)
|
||||||
--comparison=<comparison> : (str) logical comparison, (eq | ne | g | ge | l | le)
|
--comparison=<comparison> : (str) logical comparison, (eq | ne | g | ge | l | le)
|
||||||
--page=<page> : (int) page to view within paginated output
|
--page=<page> : (int) page to return during paginating
|
||||||
--page_size=<page_size> : (int) size of each page within paginated output
|
--page_size=<page_size> : (int) number of items on page during pagination
|
||||||
|
|
||||||
Returns: {Paginated[Output]}
|
Returns: {Paginated[Output]}
|
||||||
"""
|
"""
|
||||||
|
@ -1805,7 +1805,9 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
sort, reverse, comparison, **kwargs
|
sort, reverse, comparison, **kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
if None not in (page, page_size):
|
if page is not None or page_size is not None:
|
||||||
|
page = page or 1
|
||||||
|
page_size = page_size or 10
|
||||||
total_items = len(file_list)
|
total_items = len(file_list)
|
||||||
offset = page_size * (page-1)
|
offset = page_size * (page-1)
|
||||||
return {
|
return {
|
||||||
|
@ -1818,7 +1820,6 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
|
|
||||||
return file_list
|
return file_list
|
||||||
|
|
||||||
|
|
||||||
@requires(STREAM_MANAGER_COMPONENT)
|
@requires(STREAM_MANAGER_COMPONENT)
|
||||||
async def jsonrpc_file_set_status(self, status, **kwargs):
|
async def jsonrpc_file_set_status(self, status, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -165,15 +165,15 @@ class FileCommands(CommandTestCase):
|
||||||
file_list = self.daemon.jsonrpc_file_list()
|
file_list = self.daemon.jsonrpc_file_list()
|
||||||
self.assertIsInstance(file_list, list)
|
self.assertIsInstance(file_list, list)
|
||||||
|
|
||||||
# Should return a list
|
# Should paginate
|
||||||
file_list = self.daemon.jsonrpc_file_list(page=1)
|
file_list = self.daemon.jsonrpc_file_list(page=1)
|
||||||
self.assertIsInstance(file_list, list)
|
self.assertIsInstance(file_list, dict)
|
||||||
|
|
||||||
# SHould return a list
|
# Also should paginate
|
||||||
file_list = self.daemon.jsonrpc_file_list(page_size=212312)
|
file_list = self.daemon.jsonrpc_file_list(page_size=212312)
|
||||||
self.assertIsInstance(file_list, list)
|
self.assertIsInstance(file_list, dict)
|
||||||
|
|
||||||
# Should return a paginated dict holding the list
|
# Definitely should paginate
|
||||||
file_list = self.daemon.jsonrpc_file_list(page=1, page_size=50)
|
file_list = self.daemon.jsonrpc_file_list(page=1, page_size=50)
|
||||||
self.assertIsInstance(file_list, dict)
|
self.assertIsInstance(file_list, dict)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue