Skip to content

Conversation

@dmbf29
Copy link
Owner

@dmbf29 dmbf29 commented May 25, 2021

Closes #30

Screen Shot 2021-05-25 at 10 10 35

Screen Shot 2021-05-25 at 10 11 55

This is not the ideal way to get the scores but something to start with

json.points user.predictions.count(&:correct?) * 3

@dmbf29 dmbf29 added the enhancement New feature or request label May 25, 2021
@dmbf29 dmbf29 requested a review from trouni May 25, 2021 01:12
Comment on lines 15 to 25
if competition
Leaderboard.includes(:memberships).where(
competition: competition,
memberships: { user: self }
).or(Leaderboard.where(
user: self,
competition: competition
))
else
Leaderboard.includes(:memberships).where(memberships: { user: self }).or(Leaderboard.where(user: self))
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it could be simplified to:

leaderboards = Leaderboard.includes(:memberships).where(memberships: { user: self }).or(Leaderboard.where(user: self))
leaderboards = leaderboards.where(competition: competition) if competition

Copy link
Owner Author

Choose a reason for hiding this comment

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

fixed. but also have to return leaderboards after if i do that.

def index
@competition = Competition.find(params[:competition_id])
# @leaderboards = current_user.leaderboards(@competition)
@ranking = 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this for?

Copy link
Owner Author

Choose a reason for hiding this comment

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

whoops. i was messing around and forgot to remove it.

Copy link
Collaborator

@trouni trouni left a comment

Choose a reason for hiding this comment

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

Cooool 🔥

@dmbf29 dmbf29 merged commit a2ad5ba into main May 26, 2021
@dmbf29 dmbf29 deleted the leaderboards-index branch May 26, 2021 10:30
yannklein pushed a commit to yannklein/predictor-api that referenced this pull request Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement missing API routes (leaderboards, etc.)

3 participants