You are viewing a single comment's thread from:

RE: Steem Dev Series #5 - How steemit uses steemjs for getDiscussions

in #steemdev7 years ago

Thanks for sharing! Is there a way to query posts by time elapsed? I'd like to get posts starting from 15 minutes old and can't figure out how to do it except load a big amount of posts and then filter them out.

Sort:  

You are going to have to find a post that is fifteen minutes old and then use it as the start author and start permlink. The fastest way to do this would be to load a bunch of posts and then do a binary search although the easiest is going to be to load a bunch and just iterate through them looking for the first one that is 15 minutes old. Your list of posts you are looking through is going to be a relatively small set so no real performance hit from just traversing the array in order. I would suggest using the truncate_body argument and set to one since your first call is only to find your start post you don't really need the body for that.

Thank you for the detailed reply, will try this approach. A query date parameter would be very helpful and it's strange that it's missing — I can't imagine how one could get year old posts otherwise.

I am assuming it is just to make the point but if you really wanted posts that old you would probably want to set up your own database at that point that contained the metadata for all posts.

Thanks, good to know!

Coin Marketplace

STEEM 0.19
TRX 0.14
JST 0.029
BTC 64689.27
ETH 3135.60
USDT 1.00
SBD 2.56