Updates on Tower (Hivemind + REST)

in #utopian-io6 years ago (edited)


Tower is a REST API service on the top Hivemind. It allows you to query a Hivemind database in terms of REST practices.

I have pushed a couple of updates to the Tower in the last couple of days.

Filtering posts by tags (including multiple selections)

With the traditional RPC nodes, you can only filter posts with one tag. If you need to see the posts have both tagA and tagB, it's not possible.

Since Hive stores an intersection table between posts and tags, it is possible to query the database for multiple tag filtering. Here is an example SQL query demonstrates that:


SELECT author, 
       permlink 
FROM   hive_posts 
WHERE  id IN (SELECT post_id 
              FROM   hive_post_tags 
              WHERE  tag = 'python' 
              intersect 
              SELECT post_id 
              FROM   hive_post_tags 
              WHERE  tag = 'development' 
              intersect 
              SELECT post_id 
              FROM   hive_post_tags 
              WHERE  tag = 'utopian-io') 
ORDER  BY created_at DESC 
LIMIT  10; 

This query returns the last 10 post with the tags: utopian-io, development, and python. Using that query, I have implemented a filter_by_tags sub-route on the post_cache.

If you want to get the same list with Tower:

You can add any amount of tags to the filter.

Route changes on /api/v1/posts and api/v1/post_cache

To retrieve a Post object or PostCache object, tower was expecting an internal ID (id on the PostgreSQL) in the detail endpoint.

Since STEEM post objects are unique with the author/permlink couple, I have changed to use author/permlink instead of IDs.

Examples:

Note: It's required for clients' to update their logic on these endpoints since this change is not backward compatible.

Resteems

Hive stores Resteem actions in its hive_reblogs table. Tower wasn't exposing that table before, but it's now possible to get the Resteem info in different ways.

  • Account's resteems (/api/v1/accounts/<user>/reblogs)


My reblogs are accessible at /accounts/emrebeyler/reblogs/

  • Post's resteems (post_cache/<author>/<permlink>/reblogs/)

Votes to the Post

Also added a new endpoint to the post_cache namespace where you can a get a list of votes on a specific post.


Link

Each vote object includes voter, rshares, and percent:


  {
    "voter": "raphaelle",
    "rshares": "1626665936",
    "percent": "300"
  }

  • Reputation field is not exposed since it doesn't have a real use case here.

Public tower nodes

Pull Requests

Vote for my witness

I do my best to support the blockchain with my skills. If you like what I do, consider casting a vote on via Steemconnect or on steemit.com

Sort:  
  • Great post with images, code samples and instructions.
  • Very nice progression for this project.

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]

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

It's good we have in our community people who take care of the technical aspects as well.

Thanks for all your hard work on this :) I've updated my tower node now

Thanks for the fast upgrade! :-)

Hi @emrebeyler!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Thanks @emrebeyler for your hard work :)

You should be top20 witness with so much work done towards Hivemind.

Thank you for the kind words! 🙈

Congratulations @emrebeyler!
Your post was mentioned in the Steem Hit Parade in the following category:

  • Pending payout - Ranked 9 with $ 68,93

This post has been included in the latest edition of SoS Daily News - a digest of all you need to know about the State of Steem.

Hey, @emrebeyler!

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!