A custom Hivemind for TravelFeed
This is a response to the task request that we from TravelFeed put up a few weeks ago. Since nobody was interested in taking on the task request but it is essential for further development of our API, I did it myself.
Hivemind is an open-source microservice developed by Steemit. Inc that syncs information from the Blockchain such as posts and authors in a database, making it easy to query them. With my modifications, information essential to TravelFeed such as the location of a post and its curation score (=vote by @travelfeed) are synced to the database as well. Thanks to these changes, queries like this can now be made from our GraphQL API that will soon power our dApp (more about that in a later post):
The latitude and longitude are currently extracted from @steemitworldmap snippets in the post body while the post is processed by Hivemind to insert it to
hive_posts_cache. As soon as we have agreed on a common standard with other dApps to save location data in the json_metadata, these information will be used instead if present. The latitude and longitude are then sent to Nominatim, a free reverse geocoder by the Openstreetmap project, to obtain location information such as the country, subdivision and, if applicable, also the city and suburb. The openstreetmap ID and type are saved as well - later, when these information are passed from the json_metadata along with the latitude and longitude, the OSM ID and type can be used to obtain further information such as the location name in different languages.
New Features (PR #2)
The following modifications were made to Hivemind to create a customised instance fit for the needs of TravelFeed:
Valid posts with a minimum word count of 250 words and travelfeed in the tags and/or category are marked with true in the new column
is_travelfeed. Defaults to false.
Add columns for
osm_id. The post body is scanned for a SteemitWorldMap code snippet, osm_type and osm_id are obtained from Nominatim (see below). Default to NULL.
Add columns for
suburb, all provided by Nominatim using geopy. Default to NULL.
Add column for
curation_score: Percentage of vote by @travelfeed. Defaults to 0.
total_votesto show the "travelfeed miles", each vote is counted by its percentage (0-10)
- Add columns for
couchsurfingpopulated from the json_metadata. Default to NULL.