IFRCGo / go-api

MIT License
14 stars 6 forks source link

Create District entities for Countries that have 0 Districts #1349

Open batpad opened 2 years ago

batpad commented 2 years ago

Is your feature request related to a problem? Please describe.

Per email discussion:

There are countries in the GO database that have 0 districts. This is correct, because those countries do not have any admin1 divisions. The problem is that for either data consumers or within GO, if we need to associate data with admin1 entities, this becomes a very painful special case to handle: i.e. that for some cases the data would need to be associated with the Country entity if its number of districts was 0.

Describe the solution you'd like

Therefore, it is proposed to, for countries that have 0 districts, create one District entity attached to that country with the same name as the Country. Then, data can still be attached to a District entity, and it is easy for data consumers to understand that a country with only 1 district means that there are no admin1 subdivisions for that country.

We may want to add a boolean field to District to indicate that the District is of this special type, but I would really like to avoid adding more magic boolean fields unless we really need to and there is a real use-case. In this case, we can infer this by checking if the District is the only District in that Country.

So, for now:

Let's hear from @jhenshall / @geohacker on what we should do with the district code field in these cases, but @szabozoltan69 I think we can go ahead and work on this, perhaps test it out on staging - it's probably easiest to run this either as a management command or a one-time SQL in the database, whichever seems more convenient.

cc @tovari @geohacker @jhenshall

batpad commented 2 years ago

Sorry did not tag you here - @vdeak

vdeak commented 2 years ago

Added the following districts to staging:

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">

id | name | code | country_id -- | -- | -- | -- 3623 | American Samoa | ASM | 318 3620 | Antarctica | ATA | 230 3622 | Aruba | ABW | 231 3624 | Bouvet Island | BVT | 319 3625 | British Indian Ocean Territory | IOT | 320 3618 | British Virgin Islands | VGB | 321 3619 | Cayman Islands | CYM | 322 3626 | Christmas Island | CXR | 323 3627 | Cocos (Keeling) Islands | CCK | 324 3628 | Falkland Islands (Malvinas) | FLK | 325 3629 | Faroe Islands | FRO | 326 3617 | Greenland | GRL | 327 3630 | Guam | GUM | 328 3631 | Guernsey | GGY | 329 3632 | Heard Island and McDonald Islands | HMD | 330 3633 | Isle of Man | IMN | 331 3634 | Jersey | JEY | 332 3621 | Macao | MAC | 279 3635 | Montserrat | MSR | 334 3636 | Norfolk Island | NFK | 335 3637 | Northern Mariana Islands | MNP | 336 3638 | South Georgia and the South Sandwich Island | SGS | 337 3639 | Turks and Caicos islands | TCA | 339 3640 | United States Virgin Islands | VIR | 340