getLeaderboard method

Future<List<LeaderboardEntryModel>> getLeaderboard(
  1. String orgId, {
  2. String period = 'all_time',
})

Implementation

Future<List<LeaderboardEntryModel>> getLeaderboard(
  String orgId, {
  String period = 'all_time',
}) async {
  // Top 100 only: the RPC has no LIMIT and returns every member ordered by
  // XP, and the screen renders each row in a non-virtualized column (audit
  // M20). PostgREST pushes this LIMIT into the SQL, bounding the transfer.
  final response = await _client
      .rpc('org_leaderboard', params: {'p_org_id': orgId, 'p_period': period})
      .limit(100);
  return (response as List<dynamic>)
      .map((r) => LeaderboardEntryModel.fromJson(r as Map<String, dynamic>))
      .toList();
}