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

List Leaderboards Endpoint #249

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

TheTedder
Copy link
Contributor

This PR essentially splits the get leaderboards endpoint into two. If you provide IDs, it'll return only the Leaderboards with those IDs; otherwise, it'll return all non-deleted Leaderboards. Closes #227

@TheTedder TheTedder requested a review from a team as a code owner October 1, 2024 23:51
@@ -51,11 +54,12 @@ public record LeaderboardViewModel
/// <summary>
/// A collection of `Category` entities for the `Leaderboard`.
/// </summary>
public required IList<CategoryViewModel> Categories { get; init; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

With this change though; we'll have to ensure we do the same thing for any future endpoint with possibly-null relations, for consistency. Imo it's fine to default to an empty array, anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All this does is not serialize it when there are no cats to be returned.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ergo the field itself won't appear in the return object, right?

Copy link
Contributor

@Eein Eein Oct 2, 2024

Choose a reason for hiding this comment

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

That could be a problem if frontend is expecting it.

I'd ask the frontend people what they would expect here.
Anecdotally the frontend teams I generally work with would expect an empty array. It just helps avoid safe access checks cluttering up the code, and having to write a new type for leaderboards with and without the field. nvm, theres optionals

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The frontend code that actually deals with the models is autogenerated so it'll mark the field as potentially absent. If they try to access it without doing a null check, it'll produce a warning.

Copy link
Contributor

@Eein Eein left a comment

Choose a reason for hiding this comment

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

Seems good to me as long as theres a tracking issue for paginating the full list.

Also I noticed that categories are on the view model, if these are returned during the list view can you test the expected behaviour of these returning and being absent? (this may be better in ViewModel tests if those exist; helps boilerplate down the road if there are special exceptions)

@TheTedder
Copy link
Contributor Author

Seems good to me as long as theres a tracking issue for paginating the full list.

Also I noticed that categories are on the view model, if these are returned during the list view can you test the expected behaviour of these returning and being absent? (this may be better in ViewModel tests if those exist; helps boilerplate down the road if there are special exceptions)

Categories are not implemented yet. We're gonna start worrying about them next "sprint" I believe so I'm just ignoring everything to do with them for now.

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.

List Leaderboards Endpoint
3 participants