Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use uint32 datatypes instead of uint64 for leaderboards #224

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions proto/leaderboard.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ message _Element {
// between 0 and 2^63-1 inclusive.
// An id can only appear in a leaderboard one time. You can't have 2 scores for 1 player,
// unless that player has 2 ids!
uint64 id = 1 [jstype = JS_STRING];
uint32 id = 1;

// The value by which this element is sorted within the leaderboard.
float score = 2;
Expand All @@ -67,9 +67,9 @@ message _Element {
// Query APIs returning RankedElement offer the familiar Element id and score tuple, but they
// also include the rank per the individual API's ranking semantic.
message _RankedElement {
uint64 id = 1 [jstype = JS_STRING];
uint32 id = 1;
float score = 2;
uint64 rank = 3 [jstype = JS_STRING];
uint32 rank = 3;
}

// Query APIs using RankRange expect a limit of 8192 elements. Requesting a range wider than
Expand All @@ -90,8 +90,8 @@ message _RankedElement {
// * 4..3
// * 0..8193
message _RankRange {
uint64 start_inclusive = 1 [jstype = JS_STRING];
uint64 end_exclusive = 2 [jstype = JS_STRING];
Comment on lines -93 to -94
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @anitarua I had to remove these annotations, it looks like that jstype is only for 64-bit type numbers, I believe JS should handle the uint32 type natively now

uint32 start_inclusive = 1;
uint32 end_exclusive = 2;
}

message _Unbounded { }
Expand Down Expand Up @@ -136,7 +136,7 @@ message _GetLeaderboardLengthRequest {
}

message _GetLeaderboardLengthResponse {
uint64 count = 1 [jstype = JS_STRING];
uint32 count = 1;
}

message _UpsertElementsRequest {
Expand All @@ -160,7 +160,7 @@ message _GetByRankResponse {
message _GetRankRequest {
string cache_name = 1;
string leaderboard = 2;
repeated uint64 ids = 3 [jstype = JS_STRING];
repeated uint32 ids = 3;
_Order order = 4;
}

Expand All @@ -172,17 +172,17 @@ message _RemoveElementsRequest {
string cache_name = 1;
string leaderboard = 2;
// You can have up to 8192 ids in this list.
repeated uint64 ids = 3 [jstype = JS_STRING];
repeated uint32 ids = 3;
}

message _GetByScoreRequest {
string cache_name = 1;
string leaderboard = 2;
_ScoreRange score_range = 3;
// Where should we start returning scores from in the elements within this range?
uint64 offset = 4 [jstype = JS_STRING];
uint32 offset = 4;
// How many elements should we limit to returning? (8192 max)
uint64 limit_elements = 5 [jstype = JS_STRING];
uint32 limit_elements = 5;
_Order order = 6;
}

Expand Down
Loading