-
Notifications
You must be signed in to change notification settings - Fork 77
[Referral] Add new teenagers leaderboard #12330
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
base: main
Are you sure you want to change the base?
Conversation
| <tr> | ||
| <td><%= user_mention user %></td> | ||
| <%# ideally we do this in all sql instead of rails %> | ||
| <td><%= Referral::Link.where(creator: user).sum { |link| link.new_users.where(teenager: true) } %></td> |
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.
Bug: Referral::Link objects are incorrectly calling the new_users method, which is only defined on Referral::Program.
Severity: CRITICAL | Confidence: High
🔍 Detailed Analysis
The view code at app/views/admin/new_teenagers_leaderboard.html.erb:16 attempts to call the new_users method on Referral::Link objects. However, the new_users method is only defined on the Referral::Program model, not on Referral::Link. This will result in a NoMethodError at runtime when the page is rendered, causing the server to crash.
💡 Suggested Fix
Refactor the view code to correctly access the new_users method, likely by accessing the associated Referral::Program object (e.g., link.program.new_users) or by defining a similar method on Referral::Link if intended.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: app/views/admin/new_teenagers_leaderboard.html.erb#L16
Potential issue: The view code at
`app/views/admin/new_teenagers_leaderboard.html.erb:16` attempts to call the `new_users`
method on `Referral::Link` objects. However, the `new_users` method is only defined on
the `Referral::Program` model, not on `Referral::Link`. This will result in a
`NoMethodError` at runtime when the page is rendered, causing the server to crash.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 5710073
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary of the problem
Describe your changes