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

Add cabinet memberships to term table #15615

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

chrismytton
Copy link
Contributor

What does this do?

Outputs cabinet memberships on term table page.

Why was this needed?

We want to output cabinet memberships a member has held in order to finish #24.

Relevant Issue(s)

Fixes #24

Implementation notes

This adds some methods to the lib/everypolitician_extensions.rb file which augments the everypolitician-ruby and everypolitician-popolo gems. Currently the logic for connecting a person to a cabinet membership is in the PersonCard class, as it doesn't really make sense trying to shoehorn it into the Popolo classes.

Screenshots

cabinet-memberships

Notes to Reviewer

  • I'm not very happy with the tests in this pull request. I'm open to suggestions on how these can be improved.
  • The tests are still using quite an old version of countries.json, so it's testing against an older format of CSV
  • This only filters out positions with no start_date, it doesn't do anything about the type column. I don't think this is an issue because positions.csv now only holds cabinet data (as per Add README for unstable position data interface #15609 (review)).
  • It's quite possible I'm trying to change too much at once in this pull request. Happy to try splitting it up if needed.

This documents the new (and currently unimplemented)
`PersonCard#cabinet_memberships` method. This method will be used to
return the cabinet memberships for the current person card.
These docs were originally put here when we thought we'd be adding some
bits that would be more useful for external people. As it turns out
we've ended up adding the logic to mostly internal classes for now, so
we're documenting that in the classes themselves.
We're about to start making another request for the unstable positions
CSV on the term table, so I'm adding this method so we've got one place
to update what needs stubbing for a term table request.
This means that we can update the stubs needed for the term table
without having to update the individual term table tests.
This method uses the unstable positions CSV to get a list of cabinet
memberships for the legislature that the method is called on.
This methods uses the Legislature#cabinet_memberships method to get a
list of cabinet positions for the whole legislature, then filters that
list to only include positions relevant to the current LegislativePeriod
instance.
We want to make a request for unstable/positions.csv on each term table
page, so we need to stub those requests correctly in the stub_term_table
method and add the relevant data for that.
This method was previously just returning an empty array. This commit
adds an actual implementation which filters the term memberships to just
those for the person that the instance represents.
This loops through the list of cabinet positions that a person has held
in the term being viewed and outputs the label along with start and end
dates where available.
@tmtmtmtm
Copy link
Contributor

tmtmtmtm commented Feb 27, 2017

I'm not very happy with the tests in this pull request. I'm open to suggestions on how these can be improved.

One of the advantages of testing against fixed data is that you can write concrete tests, rather than abstract ones — i.e. pick a few people with long, complex membership history, and make sure they have the correct memberships in each of a few terms.

This only filters out positions with no start_date, it doesn't do anything about the type column. I don't think this is an issue because positions.csv now only holds cabinet data (as per #15609 (review)).

I think that's a misreading of that comment. That's saying that the UK positions.csv only holds cabinet data — in many other cases (including ones that you've written tests against), there are other positions too.

It's quite possible I'm trying to change too much at once in this pull request. Happy to try splitting it up if needed.

Yep, you definitely are :)

Things like changing how the stubbing in tests works could go through separately in advance, as could the docs, and probably the library extensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants