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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/role-title-constants #155

Merged

Conversation

dphoria
Copy link
Contributor

@dphoria dphoria commented Jan 26, 2022

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 to cdp_backend/database/constants.py. This will be useful for cdp_scrapers when applying logic to ensure that a Person has only one Role with title = 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 API OfficeRecords in Seattle.

Vice Chair
Member
Chair
Councilmember
City Clerk
None
Alternate
Mayor
Council President

(You gotta love None 馃ぃ )

For OfficeRecordMemberType,

Chair
Vice Chair
Member

@dphoria dphoria added the enhancement New feature or request label Jan 26, 2022
@dphoria dphoria requested a review from BrianL3 January 26, 2022 00:16
@dphoria dphoria added the low priority Doesn't need immediate attention label Jan 26, 2022
@codecov
Copy link

codecov bot commented Jan 26, 2022

Codecov Report

Merging #155 (f5bf9e9) into main (4f8b6c7) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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              
Impacted Files Coverage 螖
cdp_backend/pipeline/mock_get_events.py 100.00% <酶> (酶)
cdp_backend/database/constants.py 100.00% <100.00%> (酶)
cdp_backend/database/models.py 100.00% <100.00%> (酶)
cdp_backend/tests/database/test_validators.py 100.00% <100.00%> (酶)
...ckend/tests/pipeline/test_event_gather_pipeline.py 100.00% <0.00%> (酶)
cdp_backend/database/functions.py 91.21% <0.00%> (+0.04%) 猬嗭笍
cdp_backend/pipeline/event_gather_pipeline.py 85.75% <0.00%> (+0.07%) 猬嗭笍

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update 4f8b6c7...f5bf9e9. Read the comment docs.

@tohuynh
Copy link
Collaborator

tohuynh commented Jan 26, 2022

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

@dphoria
Copy link
Contributor Author

dphoria commented Jan 26, 2022

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. 馃槄

@dphoria dphoria marked this pull request as draft January 26, 2022 00:38
@dphoria dphoria marked this pull request as ready for review February 7, 2022 00:42
Copy link
Member

@evamaxfield evamaxfield left a 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

Copy link
Collaborator

@isaacna isaacna left a 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!

Copy link
Collaborator

@tohuynh tohuynh left a 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.

Comment on lines 191 to 193
title = fields.TextField(
validator=validators.create_constant_value_validator(RoleTitle, True)
)
Copy link
Collaborator

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

Copy link
Contributor Author

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!

Copy link
Member

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.

Copy link
Contributor Author

@dphoria dphoria Feb 7, 2022

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),
)

Copy link
Collaborator

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

Copy link
Member

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.

Copy link
Collaborator

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

Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Member

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?

@evamaxfield evamaxfield merged commit 8743498 into CouncilDataProject:main Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request low priority Doesn't need immediate attention
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants