-
Notifications
You must be signed in to change notification settings - Fork 4
Leaderboards index #34
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
Conversation
app/models/user.rb
Outdated
| 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 |
There was a problem hiding this comment.
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 competitionThere was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
There was a problem hiding this comment.
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.
trouni
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cooool 🔥
Leaderboards index
Closes #30
This is not the ideal way to get the scores but something to start with