Class LeaderboardService
Read-only leaderboards. See ILeaderboardService.
public sealed class LeaderboardService : BaseService<CharacterEntity>, ILeaderboardService
- Inheritance
-
LeaderboardService
- Implements
- Inherited Members
Remarks
Every board is the same three statements over a different FROM clause: the rows of a page, the count of the whole board, and one character's standing. The FROM/WHERE pair for a source is built in exactly one place (BuildSource(NpgsqlDbContext, LeaderboardQuery, long)) and every statement is composed from it, so the page, the count and the standing cannot disagree about who is eligible or what the score is.
Parameters are numbered as the fragments are built, so a statement binds exactly the
parameters it references. All of them are int or long; nothing here binds
a uint, which Npgsql cannot.
Constructors
LeaderboardService(INpgsqlDbContextFactory)
Initializes a new instance of LeaderboardService.
public LeaderboardService(INpgsqlDbContextFactory dbContextFactory)
Parameters
dbContextFactoryINpgsqlDbContextFactory
Fields
MaxOffset
Deepest offset the service will read from. A board deeper than this is not browsed by page.
public const int MaxOffset = 100000
Field Value
MaxPageRows
Largest page the service will return.
public const int MaxPageRows = 200
Field Value
Methods
FetchPageAsync(LeaderboardQuery, int, int, CancellationToken)
A slice of a board, best first, with the board's size.
public Task<DatabaseResult<LeaderboardPageData>> FetchPageAsync(LeaderboardQuery query, int offset, int limit, CancellationToken cancellationToken = default)
Parameters
queryLeaderboardQueryWhich board.
offsetintZero-based position of the first row.
limitintRows to return, clamped to 1-200.
cancellationTokenCancellationTokenCancellation token.
Returns
FetchStandingAsync(LeaderboardQuery, long, CancellationToken)
One character's rank and score on a board, wherever it falls.
public Task<DatabaseResult<LeaderboardStandingData>> FetchStandingAsync(LeaderboardQuery query, long characterId, CancellationToken cancellationToken = default)
Parameters
queryLeaderboardQueryWhich board.
characterIdlongThe character.
cancellationTokenCancellationTokenCancellation token.
Returns
Remarks
Succeeds with Ranked false when the character is not on the board, which is an ordinary answer and not a failure.