Explorer.SortingHelper.apply_sorting/3
function. This function requires three arguments:
query
)sorting
)default_sorting
)Explorer.SortingHelper.sorting_params/0
, which can be one of the following tuples:
{ordering, column}
{ordering, column, binding}
{:dynamic, column, ordering, Ecto.Query.dynamic_expr()}
ordering
can be :asc
, :asc_nulls_first
, :asc_nulls_last
, :desc
, :desc_nulls_first
, or :desc_nulls_last
.column
is an atom representing the column name to sort by.binding
is an atom denoting the association or binding to use for the column.Explorer.SortingHelper.page_with_sorting/4
function in conjunction with ordering. It uses the provided paging_options
along with the sorting parameters to return a paginated query.
We use cursor based pagination because blockchain data may be quite large. After merging default and user provided sorting options we generate a dynamic query with a recursive condition for each column.
Blockscout employs cursor-based pagination for efficient handling of large blockchain datasets. This approach is facilitated by the Explorer.SortingHelper.page_with_sorting/4
function, which integrates sorting parameters with pagination options.
page_with_sorting
function accepts the following arguments:
tokens_sorting/1
function: