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

Leaderboard: Add limit/offset params #256

Closed

Conversation

arinze19
Copy link

@arinze19 arinze19 commented Jan 9, 2023

Because

Current bot implementation fetches ALL users from API on command !leaderboard and this may cause performance issues

This PR

  • Update snapshots
  • set n and start as limit and offset parameters to API call respectively
  • default to n=5 and start=0 if no argument provided

Issue

Closes #175

Additional Information

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this PR follows the location of change: brief description of change format, e.g. Callbacks command: Update verbiage
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • If this PR addresses an open issue, it is linked in the Issue section
  • If this PR adds new features or functionality, I have added new tests
  • If applicable, I have ensured all tests related to any command files included in this PR pass, and/or all snapshots are up to date

@arinze19 arinze19 changed the title ft: add params-offset params Leaderboard: Add limit/offset params Jan 9, 2023
Copy link
Member

@01zulfi 01zulfi left a comment

Choose a reason for hiding this comment

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

Everything looks solid 🔥

I have a small reservation, please share your thoughts 👇

botCommands/leaderboard.js Show resolved Hide resolved
if (user) {
// on user leave guild: remove user from server?
Copy link
Member

Choose a reason for hiding this comment

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

Not sure what the purpose of this comment is.

Copy link
Author

Choose a reason for hiding this comment

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

);
const data = users.data.filter((user) => guild.members.cache.get(user.discord_id));
Copy link
Member

Choose a reason for hiding this comment

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

I get why you've removed this line where we validate if the user exists in the guild. But without this filtering, we'll end up displaying "UNDEFINED" in our leaderboard. This is what I mean:

image

Even if we keep this filter, it won't have a huge effect because we're always fetching a subset of the leaderboard. One way to tackle this would be to still display the points and rank on the leaderboard with "User left the server" instead of username. Or maybe not do anything at all? I'll also discuss with the team. Do share your thoughts, thanks!

Copy link
Author

Choose a reason for hiding this comment

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

Yeah that was very much the purpose of this comment earlier.
Perhaps we could trigger an API call that removes the user details from the API once they leave or are banned from the guild?

@arinze19 arinze19 requested a review from 01zulfi January 16, 2023 13:14
Copy link
Member

@01zulfi 01zulfi left a comment

Choose a reason for hiding this comment

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

After discussing with the team, we feel that the leaderboard would lose its value if it includes users who have left the server. Hence, ideally we would like to avoid that.

Perhaps we could trigger an API call that removes the user details from the API once they leave or are banned from the guild?

This needs more thought as well, since we'll have to consider scenarios where a user leaves the server or gets banned, and then comes back.

The issue needs more work put into it (both in the bot and the API) than initially thought. Fortunately, the leaderboard command works as intended right now and it's unlikely we'll run into performance issues anytime soon.

Putting this PR and the issue on hold now. Thanks for all the work you put in @arinze19 🚀

@01zulfi 01zulfi added the Status: On Hold There is a temporary hold on any continued work or review label Jan 19, 2023
@01zulfi 01zulfi closed this Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: On Hold There is a temporary hold on any continued work or review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Chore: Use Limit and Offset Params when Fetching the Points from The API in the Leaderboard command
2 participants