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!(ranking): Add new methods for the different ranking modes on GetRanking #34

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ashquarky
Copy link
Member

There's 5 different types of GetRanking call, asking for:

  • global leaderboards
  • global leaderboards, nearby to your own rank
  • only your friends
  • only your friends, nearby to your own rank
  • your own ranking only

These are pretty fundamentally different requests that would need different db queries, etc. at the implementation level. Notably all but the first need knowledge of the PID of the user making the request (to get their rank and their friends).

Changes:

Add new methods to the protocol for each of these use cases.

Submitting as a draft because I know if rankingMode.Value == 0 { is the wrong way to do it, but I couldn't find any other protocol with constants like that for me to reference against. If someone count point out where I should define constants for this sort of thing I'll happily clean up the magic numbers.

There's a highly WIP implementation of this API here: https://github.com/ashquarky/puyo-wiiu/blob/ranking/datastore/puyo_ranking.go

Note the dramatically different database requests needed for each mode.

…tRanking

There's 5 different types of GetRanking call, asking for:
- global leaderboards
- global leaderboards, nearby to your own rank
- only your friends
- only your friends, nearby to your own rank
- your own ranking only

These are pretty fundamentally different requests that would need different
db queries, etc. at the implementation level. Notably all but the first
need knowledge of the PID of the user making the request (to get their rank
and their friends).

Add new methods to the protocol for each of these use cases.
@DaniElectra
Copy link
Member

We define the relevant constants for protocols inside nex-protocols-go. See this example: https://github.com/PretendoNetwork/nex-protocols-go/blob/master/nintendo-notifications/notification_types.go

We could also replace that big if statement with a switch case

var rankDataList *types.List[*ranking_types.RankingRankData]
var totalCount uint32

if rankingMode.Value == 0 {
Copy link

@ItzSwirlz ItzSwirlz Jul 24, 2024

Choose a reason for hiding this comment

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

Suggested change
if rankingMode.Value == 0 {
switch rankingMode.Value {
case 0:
rankDataList, totalCount, err = commonProtocol.GetRankingsAndCountByCategoryAndRankingOrderParam(category, orderParam)
case 1:
rankDataList, totalCount, err = commonProtocol.GetNearbyRankingsAndCountByCategoryAndRankingOrderParam(callerPid, category, orderParam)
case 2:
rankDataList, totalCount, err = commonProtocol.GetFriendsRankingsAndCountByCategoryAndRankingOrderParam(callerPid, category, orderParam)
case 3:
rankDataList, totalCount, err = commonProtocol.GetNearbyFriendsRankingsAndCountByCategoryAndRankingOrderParam(callerPid, category, orderParam)
default: // rankingMode.Value == 4
rankDataList, totalCount, err = commonProtocol.GetOwnRankingByCategoryAndRankingOrderParam(callerPid, category, orderParam)
}

man I still cant figure out suggestions with GitHub for multiple lines

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