-
Notifications
You must be signed in to change notification settings - Fork 97
Merchants: Display all merchants on Settings page #281
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
Merchants: Display all merchants on Settings page #281
Conversation
WalkthroughIndex action in the family merchants controller now reads merchants from Changes
Sequence Diagram(s)(omitted — change is a single-association swap with no control-flow impact) Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (4)app/**/*.rb📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.rb📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{rb,js,jsx,ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
app/{models,controllers,views}/**/*.{rb,erb}📄 CodeRabbit inference engine (.cursor/rules/project-conventions.mdc)
Files:
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/controllers/family_merchants_controller.rb(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
app/**/*.rb
📄 CodeRabbit inference engine (AGENTS.md)
Place Rails application Ruby code (models, controllers, services, jobs, mailers, components) under app/
Files:
app/controllers/family_merchants_controller.rb
**/*.rb
📄 CodeRabbit inference engine (AGENTS.md)
Ruby style: 2-space indentation; snake_case for methods/variables; CamelCase for classes/modules
Files:
app/controllers/family_merchants_controller.rb
**/*.{rb,js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{rb,js,jsx,ts,tsx}: Make changes atomic, testable, and explain their impact briefly in code suggestions.
Respect existing tests and add tests when changing critical logic.
Files:
app/controllers/family_merchants_controller.rb
app/{models,controllers,views}/**/*.{rb,erb}
📄 CodeRabbit inference engine (.cursor/rules/project-conventions.mdc)
Avoid N+1 queries
Files:
app/controllers/family_merchants_controller.rb
🔇 Additional comments (1)
app/controllers/family_merchants_controller.rb (1)
8-8: I need to verify the Family model's associations and check for N+1 query concerns. Let me run additional verification:I need to verify the Family model definition and check line 48 for comparison:
Let me search the codebase more directly for the Family model and the controller code:Based on the previous script execution output and my web research, I can now provide a comprehensive analysis. The original script confirmed that the
alphabeticallyscope exists on the Merchant model (line 10) with onlyorder(:name). However, the ast-grep pattern didn't find the Family model's merchants association - this could mean either the association doesn't exist, or the pattern didn't match it properly.Let me generate the final rewritten review comment based on the verification performed:
Verify the
merchantsassociation on the Family model and check for N+1 query prevention.The change from
assigned_merchantstomerchantsaligns with the PR objectives to display all merchants. To prevent N+1 queries with associations, ensure the merchants collection is eager loaded usingincludes,preload, oreager_load—withincludesbeing the recommended default choice.The
alphabeticallyscope on the Merchant model only orders by name and doesn't include preloading. Verify:
- That the Family model actually defines
has_many :merchants- Whether merchants are accessed in a loop within the view or controller for this action
- Whether
.includes(:merchants)is applied to the query in the controller or through a default scope
|
Since you just touched that code, can you review @sokie? |
sokie
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.
I think we should allow both FamilyMerchant and ProviderMerchant support in the settings page, because it's weird to have merchants in the db and not available in the UI.
But I also see that adding ProviderMerchant needs more extensive Controller changes.
Good catch and we'll merge this!
Noticed that on the Merchants settings page, only merchants that are used on at least one transaction are displayed. This makes it impossible to remove or edit a merchant if it's unused on a transaction.
This page now lists all merchants.
Summary by CodeRabbit