-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
feature: add automatic field detection in resources #3516
base: main
Are you sure you want to change the base?
feature: add automatic field detection in resources #3516
Conversation
end | ||
|
||
# Discovers and configures database columns as fields | ||
def discover_columns(only: nil, except: nil, **field_options) |
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.
Method discover_columns
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
end | ||
end | ||
|
||
def discover_attachments |
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.
Method discover_attachments
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
end | ||
end | ||
|
||
def discover_basic_associations |
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.
Method discover_basic_associations
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Code Climate has analyzed commit b30d05a and detected 3 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
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.
This is amazing, @ObiWanKeoni!
I've been testing some scenarios locally, and it's awesome!
I took a look at the code, and it's fantastic that you managed to keep it within the HasFieldDiscovery
concern. This will undoubtedly make our review much easier!
Congratulations on this incredible work!
We'll provide a detailed code review once we validate the DSL and its behavior.
This PR has been marked as stale because there was no activity for the past 15 days. |
Description
Fixes #3390
This is my working prototype for the issue linked above. It inspects the model much like the resource generator in:
https://github.com/avo-hq/avo/blob/617ead62d09f3f8c04a7438c5fc7cc461f5fcee8/lib/generators/avo/resource_generator.rb
As it gathers all of the columns and associations, it calls the
#field
method to add a field item dynamically. I've added a new User resource with many different use cases of thediscover_columns
anddiscover_associations
methods.Important
As I am still very new to contributing here, I am unfamiliar with some of the design patterns and decisions made thus far in Avo. I would advise that reviewers pay special attention to whether I have broken patterns necessary for cleanliness and readability. There may also be opportunities for refactoring and applying these discovered fields to, say, tab groups but I wanted to get initial feedback before proceeding with the patterns I've established so far.
Checklist:
Screenshots & recording
Manual review steps
Manual reviewer: please leave a comment with output from the test if that's the case.