mshd / wikitree

Tree structure of Wikidata entities (previous version here
https://mshd.github.io/wikitree/public/
GNU General Public License v3.0
8 stars 5 forks source link

Show City/Country instead of Village/Hospital for birth and death #15

Closed mshd closed 4 years ago

mshd commented 4 years ago

This is a bit of a tricky task. As you see Barack Obama (tree was born in Kapiolani Medical Center for Women and Children. Nobody cares about the hospital, they value in need in Honolulu or Hawaii. Now we need to make another request to see if the birth place is not a locality (or a hospital). That is possible by using P31 (instance of). Then get the label for the property located in the administrative territorial entity P131 or location P276

I also don't know what's the best way to tackle it.

edwinindrajayas commented 4 years ago

By calling callback from different route depends on if there is place with instance of hospital. First, populate the place of birth and place of death Ids in the each node to the array that will be checked on the last iteration callback. After that, check if there is label that is an instance of hospital, then call the API and wait for the response using async await Promise before calling callback function. if it's not instance of hospital then process the label and callback as usual