-
Notifications
You must be signed in to change notification settings - Fork 26
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/role-title-constants #155
feature/role-title-constants #155
Conversation
Codecov Report
@@ Coverage Diff @@
## main #155 +/- ##
==========================================
+ Coverage 94.53% 94.57% +0.03%
==========================================
Files 50 50
Lines 2543 2560 +17
==========================================
+ Hits 2404 2421 +17
Misses 139 139
Continue to review full report at Codecov.
|
Also, don't know if you want to add it to this PR, but a validator needs to be added to https://github.com/CouncilDataProject/cdp-backend/blob/main/cdp_backend/database/models.py#L190. See an example of a constant validator: https://github.com/CouncilDataProject/cdp-backend/blob/main/cdp_backend/database/models.py#L612 |
Ohhh thank you so much. I'm switching this PR to draft for now then. 😅 |
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.
Looks good to me! Thanks! Will let one of the front end folks approve too before merge
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.
Looks good to me!
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.
Thanks for adding the validator. Looks good.
I have one clarifying question.
cdp_backend/database/models.py
Outdated
title = fields.TextField( | ||
validator=validators.create_constant_value_validator(RoleTitle, True) | ||
) |
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 notice that the other required constant field like matterstatus.status
have a required=True
, while this one doesn't. It doesn't matter that it is missing right, as long the second arg to create_constant_value_validator
is True
?
cc @isaacna @JacksonMaxfield
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.
Oops that's my mistake. Thank you for catching that!
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.
Yea this is just a styling thing. The second arg of True
will be used for the required
kwarg. Can include or not.
The only reason why I commonly include the full kwarg name is because if we ever change the API, and we shift the order of the arguments, the kwargs still get filled properly regardless of the order. But I don't think we plan on changing the arg order haha. Either way, I'm not concerned.
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 should still probably fix it to set required
for fields.TextField()
, i.e.
title = fields.TextField(
required=True, # this one
validator=validators.create_constant_value_validator(RoleTitle, True),
)
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 had the same thought earlier but also agree that keeping the arg name is not a big deal. I think we can add them for Jackson's reasons above and also readability. Earlier I was gonna comment why we changed title
to not be required, but then I saw that True
was for is_required
. If we add the arg name it becomes more clear
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.
Oh woops. Yes, you should set it for the TextField I believe.
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 if we set the FireO arg required
, than we can just get rid of the is_required
field in create_constant_value_validator
. Same goes for everywhere else since I don't think it really adds any functionality
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.
Isaac's suggestion makes sense, we only need one way to check if something is required.
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'll change as above, but I guess this is food for thought for the future then.
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.
Agree. Change to match others for now. Can you open an issue to track the above thoughts as well?
Link to Relevant Issue
This pull request is a prerequisite for resolving CouncilDataProject/cdp-scrapers#66
Description of Changes
Include a description of the proposed changes.
Added
RoleTitle
string constants tocdp_backend/database/constants.py
. This will be useful forcdp_scrapers
when applying logic to ensure that aPerson
has only oneRole
withtitle = RoleTitle.COUNCILMEMBER
per term.I took
RoleTitle
members verbatim from Jackson's suggestions in this comment. Certainly open to additions, modifications, etc.For reference, below is the entire unique list of
OfficeRecordTitle
from all Legistar APIOfficeRecords
in Seattle.(You gotta love
None
🤣 )For
OfficeRecordMemberType
,