Skip to content

Conversation

@crystaltine
Copy link

Sorts the db fetch by num points (descending) in the /:hexathonId/users route

todo: we can maybe make this contingent on a request param. This change is primarily for the points leaderboard on livesite.

@crystaltine crystaltine requested a review from Copilot September 27, 2025 18:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds sorting functionality to the hexathon users endpoint to return users ordered by their collected points in descending order, with a secondary sort by name in ascending order. This change supports the implementation of a points leaderboard feature on the live site.

  • Adds database query sorting by points.numCollected (descending) and name (ascending)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

const offset = parseInt(req.query.offset as string) || 0;
const hexathonUsers = await HexathonUserModel.accessibleBy(req.ability)
.find(filter)
.sort({ "points.numCollected": 'desc', name: 'asc' })
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

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

Consider adding a database index on points.numCollected and name fields to optimize this sorting operation, especially if this endpoint will be frequently accessed for leaderboard functionality.

Copilot uses AI. Check for mistakes.
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.

1 participant