Skip to content

Instantly share code, notes, and snippets.

@tmtmtmtm
Last active July 13, 2020 05:51
Show Gist options
  • Save tmtmtmtm/98e7234c6d444386332f05f6fc6b00f9 to your computer and use it in GitHub Desktop.
Save tmtmtmtm/98e7234c6d444386332f05f6fc6b00f9 to your computer and use it in GitHub Desktop.

A bunch of French municipal elections are showing up on the Recent elections with no Country report. Looking at some of those, it seems there's also a bit of a mismatch of modelling, with some being 'instance of: French municipal elections 2020', and some 'instance of: municipal election'+'part of: French municipal elections 2020'. The latter seems better to me, so I'm going to also migrate all the former to that whilst I'm here.

So, to select those:

SELECT ?item ?itemLabel WHERE {
  ?item wdt:P31 wd:Q60846649 .
  FILTER NOT EXISTS { ?item wdt:P17 [] }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Then migrate those to being 'instance of: municipal election', 'part of: French municipal elections 2020' via Petscan: http://petscan.wmflabs.org/?psid=16769267&al_commands=P31%3AQ152450%0A-P31%3AQ60846649%0AP361%3AQ152450%0A

These ran as QS batch: https://editgroups.toolforge.org/b/QSv2T/1594617861615/

Doh! I left my 'check that they're not in France' in that query, so now we need another couple of loops of this. First, I'll add 'P17:Q142' (country: France) to those ones, via a second QS batch against the same item list: https://editgroups.toolforge.org/b/QSv2T/1594618013730/

And then repeat the first process again for the ones that do already know they're in France:

SELECT ?item ?itemLabel WHERE {
  ?item wdt:P31 wd:Q60846649 .
  ?item wdt:P17 wd:Q142.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

That one was batch https://editgroups.toolforge.org/b/QSv2T/1594618103955/

In total that's 122 elections migrated to a better model, and then 113 of those also got the original goal — a new 'country: France' claim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment