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

feat: leaderboard bug bash fixes, updated response classes #966

Merged
merged 1 commit into from
Oct 12, 2023

Conversation

anitarua
Copy link
Contributor

@anitarua anitarua commented Oct 12, 2023

Ticket #468. Addresses feedback we got from the bug bash.

Changes include:

  • Removes the Found and NotFound response classes which were confusing.
    • Error is returned when the cache is not found and thus the request failed.
    • Success is returned when the cache was found, but does not necessarily mean that requested elements were found (e.g. fetching data from empty or non-existent leaderboards will return length=0 or elements=[] rather than NotFound now).
  • Removes the leaderboard prefixes from the Leaderboard methods.
    • E.g. leaderboardUpsert --> upsert
  • Upsert can now accept elements of type Record<number, number> | Map<number, number> instead of just Map<number, number>.
  • fetchByRank now requires startRank and endRank for pagination through leaderboards.

Will fast follow to update the nodejs example and doc example snippets after this is released. Those haven't made it into the dev docs yet.

return convertedElements;
}

public async leaderboardUpsert(
public async upsert(
Copy link
Contributor

Choose a reason for hiding this comment

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

this class is internal, so it's fine to change the name here, but not crucial.

I don't see the public classes in this PR?

@@ -38,10 +38,10 @@ export abstract class AbstractLeaderboard implements ILeaderboard {
* {@link LeaderboardUpsert.Success} on success.
* {@link LeaderboardUpsert.Error} on failure.
*/
public async leaderboardUpsert(
elements: Map<number, number>
public async upsert(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Public classes are in AbstractLeaderboard.ts
These are all inherited by the Leaderboard class in each package.

Copy link
Contributor

Choose a reason for hiding this comment

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

ooohhhh right and the PreviewClient classes just have .leaderboard(). Okay you're right, my bad.

public async leaderboardFetchByRank(
public async fetchByRank(
startRank: number,
endRank: number,
Copy link
Contributor

Choose a reason for hiding this comment

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

I hadn't thought about how making these required would cause us to pull them up to positional arguments, or else make the options argument required.

What you did here makes sense, but the one downside is that because JS doesn't allow callers to use keyword-style call patterns for positional arguments, you can no longer say startRank: blah in your call to these, it'll just be fetchByRank(12, 42), which isn't quite as readable.

but it is more succinct. and it seems fairly intuitive. so i think i'm on board with doing it this way, vs. keeping these inside the options interface and just making the options arg required.

@bruuuuuuuce I am curious if you have any opinion on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

:skeletor_fist_shake: nodejs 😠 .

Generally speaking, I like to use objects as params to my functions in js for this exact reason. However,

  • this is more concise
  • this is the pattern we currently have set for our other methods
  • most js sdks just use positional args like this like the redis sdk

I think its ok to ship with this

Copy link
Contributor

@cprice404 cprice404 left a comment

Choose a reason for hiding this comment

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

i think this lgtm except I think we maybe missed removing the leaderboard prefix in the function names on the public client classes?

Copy link
Contributor

@cprice404 cprice404 left a comment

Choose a reason for hiding this comment

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

i'm on board with this. i'd be fine with you merging it. i'm interested in Matt's opinion about whether startRank/endRank live in the options arg or not but i would be okay with fast-follow on that if we decided to change it, and I think i'm in favor of the way you have it now.

@anitarua anitarua merged commit 746444a into main Oct 12, 2023
13 checks passed
@anitarua anitarua deleted the leaderboard-bug-bash-followup branch October 12, 2023 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants