asobi_ops_leaderboards (asobi v0.75.1)

View Source

Leaderboard reads for the ops plane: the board list, and one board's entries.

The public leaderboard routes answer a player's question - my rank, the top 100, who is near me. Neither of them can tell an operator which boards exist, and neither can reach past row 100 of one. Both of those are asobi_leaderboards; this module is the allowlist and the paging in front of it.

The board list is sorted and paged in memory because its source is one grouped aggregate that has to run whole whatever page is asked for - see asobi_leaderboards:boards/0. The entries list is a query, paged by the database like every other list here.

Summary

Functions

The board list, filtered and ordered, ready to page.

Wire-name to column mapping the board list accepts in ?sort=.

One board's entries as an ordered query for the shared paginator.

Wire-name to column mapping the entries list accepts in ?sort=.

Positive allowlist of the fields a board summary may carry off this endpoint.

Positive allowlist of the fields a board entry may carry off this endpoint.

Functions

boards(Params)

-spec boards(asobi_ops_params:params()) ->
                {ok, {[map()], asobi_ops_params:sort_spec()}} |
                {error, {unknown_sort, binary()} | {unknown_order, binary()} | {query_failed, term()}}.

The board list, filtered and ordered, ready to page.

Ordered by size first, because the operator question behind this endpoint is usually which board is being written to. The order ends on board_id, which is what makes the offset window stable.

boards_sortable()

-spec boards_sortable() -> asobi_ops_params:sort_allowlist().

Wire-name to column mapping the board list accepts in ?sort=.

entries_query(BoardId, Params)

-spec entries_query(binary(), asobi_ops_params:params()) ->
                       {ok,
                        #kura_query{from :: atom() | module() | undefined,
                                    select :: [atom() | term()] | {exprs, [term()]},
                                    wheres :: [term()],
                                    joins :: [term()],
                                    order_bys :: [term()],
                                    group_bys :: [atom()],
                                    havings :: [term()],
                                    limit :: non_neg_integer() | undefined,
                                    offset :: non_neg_integer() | undefined,
                                    distinct :: boolean() | [atom()],
                                    lock :: binary() | undefined,
                                    prefix :: binary() | undefined,
                                    preloads :: [atom() | {atom(), list()}],
                                    ctes :: [{binary(), #kura_query{}}],
                                    combinations ::
                                        [{union | union_all | intersect | except, #kura_query{}}],
                                    include_deleted :: boolean()}} |
                       {error, {unknown_sort, binary()} | {unknown_order, binary()}}.

One board's entries as an ordered query for the shared paginator.

entries_sortable()

-spec entries_sortable() -> asobi_ops_params:sort_allowlist().

Wire-name to column mapping the entries list accepts in ?sort=.

project_board(Board)

-spec project_board(map()) -> map().

Positive allowlist of the fields a board summary may carry off this endpoint.

project_entry(Entry)

-spec project_entry(map()) -> map().

Positive allowlist of the fields a board entry may carry off this endpoint.

The same fields asobi_leaderboard_controller already returns to any player, plus the row id. metadata is game-authored and does not leave.