-
Notifications
You must be signed in to change notification settings - Fork 53
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
Fetch policy/alignment data from new location. #1752
Conversation
788fb73
to
80a779d
Compare
This creates a local JSON file of the policies from the list, rather than change the DB at present. |
f7e4026
to
a19a204
Compare
80a779d
to
81e888f
Compare
Putting my notes back in the PR for history. Following review comment explains new commits. All policy information is now loaded through the json2db.pl - running this on new instanance seems to work fine. Reference to twfy-votesURL is not hardcoded - but added as an CONF setting 'TWFY_VOTES_URL'. When we have a semi-permenemnt home we should set a default on this - although still useful to have as a config setting for testing. Meta infomrationThere is a new file /scrapedjson/policies.json that stores the polices data. This is a reprocessed version of the /policies/commons/active/all.json in twfy-votes. This specifically stores the descriptions of sets - and the assignment of specific polices to sets. This is referenced when the Policies object is constructed, and which then can be used as the old manual assigments were to display information in views. Note: it would be useful for testing if twfy-votes let you reference both active+candidate in this URL - now mysociety/twfy-votes#24 Loading policy informationAssume that no new division information is being returned, and so no longer do update checks based on that. Person policy information is set in the 'personinfo' table as keys - continuing the dreammp setup currently used. For each policy_id - fetching the twfy-compatitible popolo and reading the info in. Note: we are no longer storing this json locally as part of parlparse. Process motions - stash in database the policydivisions information (connection between policy and division) - either adding or update existing. Note: maybe here the function should be process_policydivision for clarity? This is following the existing 'motionadd, motionupdate' quieries - both of which refer to policydivisions table and could also be renamed. Addressed in follow up commit. Process alignments - for each person per vote - create or update distance, both_voted, and absent num numbers in the person info table. Meta note: We're loading policies one at at a time from twfy-votes, mirroing pw API - in principle this could be one big policies file. I don't see a massive reason to do this at this point but could. Meta note: Still pulling in attendance/rebellion info from Public Whip - which I don't think we're displaying anywhere. |
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 great!
I've made two tweaks:
- Added a longer timeout for fetching policies from twfy-votes. Was getting consistent errors on a few long ones.
- Renamed functions that dealt with the policydivision table away from 'motion' to be clearer it was about the relation of policies and divisions.
If you're happy with these - good to go.
And one more - copied how TESTING was used elsewhere. |
9a47a84
to
2d9398c
Compare
Summary set still hard-coded at present.
- Improve clarity on what 'motion' means in this context.
6cf128b
to
907235c
Compare
For #1743 (I ignored the comparison stuff in the JSON for the moment, assume I'll try and understand that at some later point; hope I've picked the right fields).
This stops fetching dream MP XML and policy JSON from PW, instead fetching JSON only from twfy-votes that contains the policy votes and alignment information. The import script no longer imports divisions, assuming they've already been imported elsewhere, only policies (if missing), policy/division links, and policy alignments.
Also fixes #1747.