diff --git a/lbry/db/queries/search.py b/lbry/db/queries/search.py index bd5549683..4363003e4 100644 --- a/lbry/db/queries/search.py +++ b/lbry/db/queries/search.py @@ -95,7 +95,7 @@ def select_claims(cols: List = None, for_count=False, **constraints) -> Select: if column == 'name': column = 'claim_name' sql_order_by.append( - f"claim.{column} ASC" if is_asc else f"claim.{column} DESC" + f"claim.{column} ASC NULLs LAST" if is_asc else f"claim.{column} DESC NULLs LAST" ) constraints['order_by'] = sql_order_by @@ -226,7 +226,7 @@ def protobuf_search_claims(**constraints) -> str: def search_claims(**constraints) -> Tuple[List[Output], Optional[int], Optional[Censor]]: total = None - if not constraints.pop('no_totals', False): + if constraints.pop('include_totals', False): total = search_claim_count(**constraints) constraints['offset'] = abs(constraints.get('offset', 0)) constraints['limit'] = min(abs(constraints.get('limit', 10)), 50) diff --git a/lbry/service/api.py b/lbry/service/api.py index 479b6d169..60118d669 100644 --- a/lbry/service/api.py +++ b/lbry/service/api.py @@ -1629,7 +1629,11 @@ class API: # kwargs['signature_valid'] = 0 page_num = abs(pagination['page'] or 1) page_size = min(abs(pagination['page_size'] or DEFAULT_PAGE_SIZE), 50) - claim_filter_dict.update({'offset': page_size * (page_num - 1), 'limit': page_size}) + claim_filter_dict.update({ + 'offset': page_size * (page_num - 1), 'limit': page_size, + 'include_totals': pagination['include_totals'], + 'order_by': order_by + }) if protobuf: return await self.service.protobuf_search_claims(**remove_nulls(claim_filter_dict)) result = await self.service.search_claims( @@ -1641,7 +1645,7 @@ class API: "page": page_num, "page_size": page_size } - if not kwargs.pop('no_totals', False): + if pagination['include_totals']: d['total_pages'] = int((result.total + (page_size - 1)) / page_size) d['total_items'] = result.total return d