Open garethrees opened 3 years ago
name = 'highways_england'
# => "highways_england"
PublicBody::Version.
where(:url_name => name).
distinct.
pluck(:public_body_id)
# => [30, 55508]
PublicBody.find(30).name
# => "Highways Agency"
PublicBody.find(55508).name
# => "Highways England Company Limited"
I've fixed the specific case (https://github.com/mysociety/whatdotheyknow-theme/issues/879#issuecomment-907123559), but really we should prevent an authority being saved if this error case is going to happen.
Just noting IPZ has also run in to this https://github.com/codeforcroatia/imamopravoznati/issues/52.
We've found this to be a problem as we are exploring how to link our data with wikidata in a similar fashion to what you did with https://www.wikidata.org/wiki/Property:P8167 (which relies on the url_name
as an id to link back to WhatDoTheyKnow).
Specifically, it is possible to change the name or short name of a public body so that its url_name
takes over a historic url_name
of another body. On the other hand, it is not possible to rename a body to cause a conflict with a current url_name
, which seems like the correct way to handle things.
Would you be interested in a small PR that prevents changing names which would result in historic name conflicts, and throws a similar error to the one raised with conflicting current names? I think this would guarantee the stability of url_name
over time, and therefore make good urls that don't change :)
Would you be interested in a small PR that prevents changing names which would result in historic name conflicts
This seems pretty sensible but I'm wondering whether there's ever a case where this would be a problem. To play this out a little…
/mod
)/mod
would be most help to our users.I think in WDTK we'd deal with this by:
/ministry_of_defence
to free up /mod
./mod
slug would be "historic"/mod
slugThis would break the wikidata linking though. It's not in our current practice to check that.
In any case, I think we should still go ahead with the PR. If we did find ourselves in this situation and really did want to break the URL, I think we could manually edit/destroy the PublicBody::Version
with the conflicting url_name
, but I agree that by default avoiding these conflicts would be best.
This is the underlying cause of the first issue described in https://github.com/mysociety/whatdotheyknow-theme/issues/879.