A custom Hivemind for TravelFeed

jpphotography
JPPhotography @jpphotographyApril 2019 · 3 min read

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):

Screenshot 20190413 at 11.24.08.png

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.

Repository

https://github.com/travelfeed-io/hivemind

New Features (PR #2)

The following modifications were made to Hivemind to create a customised instance fit for the needs of TravelFeed:

hive_posts_cache:

  • 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 latitude and longitude, osm_type and 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 osm_type, osm_id, country_code, subdivision, city, and suburb, all provided by Nominatim using geopy. Default to NULL.

  • Add column for curation_score: Percentage of vote by @travelfeed. Defaults to 0.

  • Modified column total_votes to show the "travelfeed miles", each vote is counted by its percentage (0-10)

hive_accounts:

  • Add columns for facebook, instagram, youtube, couchsurfing populated from the json_metadata. Default to NULL.

GitHub Account

https://github.com/tiotdev


Share this post



1027
Comments

I remember talking to you about these changes on Steemdevs discord server. Good to see you have already implemented.

On a side note, I see you didn't use the Hive's internal migration logic for database changes. (Example) Are there any reasons behind that?

Good work. Cheers.


Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]


99

Thanks for the review! To be honest, I didn't notice that there was a migration logic, thanks for pointing that out!


0

Thank you for your review, @emrebeyler! Keep up the good work!


0

Hey, @jpphotography!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!


0