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

Remove people that disappear from EveryPolitician #366

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chrismytton
Copy link
Contributor

When a person gets merged on Wikidata they effectively disappear from EveryPolitician, but we still have them cached in the country_uuids table. This change checks for any people that have been removed and deletes the associated votes and country_uuids tables.

Fixes #336

When a person gets merged on Wikidata they effectively disappear from
EveryPolitician, but we still have them cached in the `country_uuids`
table. This change checks for any people that have been removed and
deletes the associated `votes` and `country_uuids` tables.
gb_ids = CountryUUID.where(country_slug: country.slug, legislature_slug: legislature.slug).map(&:uuid)
missing_uuids = gb_ids - ep_ids
Vote.where(person_uuid: missing_uuids).delete
CountryUUID.where(uuid: missing_uuids).delete
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrismytton I'm assuming these are both essentially no-ops if missing_uuids is empty?

I had a quick scan of the Sequel docs, but couldn't spot anything obvious, and as there are no tests for this, I figure it's best to be overly cautious!

@tmtmtmtm tmtmtmtm assigned tmtmtmtm and chrismytton and unassigned tmtmtmtm Nov 27, 2018
@chrismytton chrismytton removed their assignment Nov 6, 2019
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.

1 politician left to play... or not
2 participants