Skip to content
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

DRY common response object database fields #107

Merged
merged 13 commits into from
Aug 22, 2023
Merged

Conversation

rmarow
Copy link
Contributor

@rmarow rmarow commented Aug 18, 2023

resolves #103

@rmarow rmarow self-assigned this Aug 18, 2023
@MattF-NSIDC MattF-NSIDC changed the title Create ObjectMixin and beginning work on applying it Create ResponseObjectFieldMixin and beginning work on applying it Aug 18, 2023
contact_title = Column(String(256), nullable=True)
contact_email = Column(String(256), nullable=False)
# how do i make it a minimum of 3 tags?
tags = Column(String, nullable=False)
Copy link
Member

Choose a reason for hiding this comment

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

@rmarow I'm not sure I understand this. I looked in the glossary and didn't see anything about a minimum number of tags. I think this should be an Array column (sqlalchemy)!

Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is hard to code, we can just add explanatory text that says "recommend three or more tags." Sandy had suggested this last week, and I added a note in the front-end document, which @rmarow noted. I think the explanatory text is a good way to go. If we do some testing and folks aren't responding to that request, we can adjust.

Copy link
Member

Choose a reason for hiding this comment

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

I agree, let's go with explanatory text and treat the actual validation as icing for later :)

@rmarow rmarow marked this pull request as ready for review August 21, 2023 20:59
only=['name', 'performance_rating'],
only=[
'short_name',
'full_name',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MattF-NSIDC is there a way to reduce the repetitiveness here?

Copy link
Member

Choose a reason for hiding this comment

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

We could save these as a re-usable list of strings!

Copy link
Member

@MattF-NSIDC MattF-NSIDC left a comment

Choose a reason for hiding this comment

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

LGTM, just a few comments to address that I think shouldn't require a second review :) Let me know if you want me to take a look again before the merge though! Happy to do it :)

@@ -29,6 +29,21 @@
User,
)

response_object_fields = [
Copy link
Member

Choose a reason for hiding this comment

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

maybe common_response_object_fields?

Copy link
Member

Choose a reason for hiding this comment

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

Also, is there a way we can generate this list from the mixin class? There are many ways to get the "fields" out of a class, but they're all pretty messy. We could make ResponseObjectFieldMixin a pydantic class, and then I think we have more intuitive access to its fields. Or we could use one of these methods:

https://stackoverflow.com/questions/9058305/getting-attributes-of-a-class

I don't feel we need to address this in this PR, except to leave a comment for future us that some DRYing needs to be done.

usaon_vta_survey/forms.py Outdated Show resolved Hide resolved
@@ -213,14 +226,6 @@ class ResponseObservingSystem(BaseModel, IORelationshipMixin):
'polymorphic_on': type,
}
Copy link
Member

Choose a reason for hiding this comment

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

id and response_id are also common fields. Can those go in the mixin as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sqlalchemy did not like when i tried to do this.

@rmarow rmarow merged commit d53b7b0 into main Aug 22, 2023
2 checks passed
@rmarow rmarow deleted the update_response_objects branch August 22, 2023 18:45
@MattF-NSIDC MattF-NSIDC changed the title Create ResponseObjectFieldMixin and beginning work on applying it DRY common response object database fields Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Response object fields should match glossary
3 participants