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

Fetch policy/alignment data from new location. #1752

Merged
merged 3 commits into from
Jan 16, 2024

Conversation

dracos
Copy link
Member

@dracos dracos commented Dec 15, 2023

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.

@dracos dracos requested a review from ajparsons December 15, 2023 17:41
@dracos dracos force-pushed the use-twfy-json-policy-json branch from 788fb73 to 80a779d Compare December 18, 2023 15:15
@dracos dracos changed the base branch from master to upgrade-phpunit December 18, 2023 15:15
@dracos
Copy link
Member Author

dracos commented Dec 18, 2023

This creates a local JSON file of the policies from the list, rather than change the DB at present.
It keeps 'summary' being hard-coded at present.

@dracos dracos force-pushed the use-twfy-json-policy-json branch from 80a779d to 81e888f Compare December 19, 2023 10:31
@ajparsons
Copy link
Contributor

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-votes

URL 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 infomration

There 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 information

Assume 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.

Copy link
Contributor

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

@ajparsons
Copy link
Contributor

And one more - copied how TESTING was used elsewhere.

@dracos dracos changed the base branch from upgrade-phpunit to master January 16, 2024 15:58
dracos and others added 3 commits January 16, 2024 16:00
Summary set still hard-coded at present.
- Improve clarity on what 'motion' means in this context.
@dracos dracos force-pushed the use-twfy-json-policy-json branch from 6cf128b to 907235c Compare January 16, 2024 16:40
@dracos dracos merged commit 907235c into master Jan 16, 2024
7 of 8 checks passed
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.

2 participants