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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/jobs/update_cache_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def perform
)
country_uuid.update(gender: person[:gender])
end
ep_ids = legislature.popolo.persons.map(&:id)
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!

end
end
end
Expand Down