Posts

HLS tool update - know your pending comment author rewards ( along with post author rewards )

avatar of @amr008
25
@amr008
·
·
0 views
·
3 min read

Good evening to everyone , I hope you all are doing good .
I just updated my HLS tool today to update an existing feature .

Post Author rewards

Couple of months ago I added this feature of "Know your pending Post author rewards " .

What it basically did is , it took all your posts in past 7 days and calculated the second layer token rewards for those posts .

It was well received by users because

  1. There aren't many places right now ( Except this tool and Marky's tool ) where you can see all second layer token rewards at the same place .
  2. We use multiple tags on most of our posts and we would like to know all tokens earned on a particular post at one place.

Comment Author rewards

But there was something missing , the comment rewards , right now there isn't any app which tells you the second layer token rewards at the same place for both comments and posts - I didn't add this to the script back then because it just took way too much time to retrieve the info .

Amount of time taken initially

So it followed the same procedure as post author rewards .

  1. Retrieve all the comments made by your account in past 7 days ( pending payouts ) .

  2. Calculate the second layer tokens rewards for each comment .

  3. Convert those second layer token rewards to Hive ( for each comment )

  4. Add everything and display the summary .

So at first when I did this , I tried with a particular username who had posted 1000 comments and it took my on an average 67 minutes to retrieve these .

Filters added

Then I started working on reducing the amount of time taken because 67 minutes is just ridiculous .

1st filter -
So the first filter that I added was to remove the comments / posts for which there were 0 upvotes .

Obviously if 0 upvotes then 0 earnings , don't even have to check how many tokens you are eligible to gain .

This reduced the time taken considerably . If an user made 1000 comments then on an average 400 comments are upvoted ( I just calculated this for 15 users so it might not be accurate ), it took 20 minutes now instead of 67 minutes .

But still that isn't enough , 20 minutes is huge too .

2nd filter

This was a game changer and I was kinda stupid to have overlooked this .

Initially for each and every comment there was an API call made to retrieve the latest token price ( to convert it to Hive ) . This was taking way too long cumulatively speaking .

So at the start of the script itself I retrieve and store all the latest token price and then for each and every comment the same price is used .

This reduced the time taken from 20 minutes to 3 minutes .

So right now , if you have say 500 comments which are upvoted ( atleast 1 upvote ) then it will take approximately 200-250 seconds to retrieve all the data .

Well that isn't fast either - 0.5 seconds for 1 comment ?

That's true . 0.5 seconds per comment ? That's huge but believe me I have done my best , I researched and looked at all possible ways to reduce the time .

If anyone has any more ideas , I would love to hear it and implement it ASAP depending on the complexity of the solution .

Finally

Steps to get the data

  1. Go to https://hivelayers-stats.herokuapp.com

  2. Choose "Post rewards" in top left.

  3. Now you will see 4 options -

    • 1st is only for a particular URL

    • 2nd is for only posts ( all pending posts )

    • 3rd is for only comments ( all pending comments )

    • 4th is for both pending posts and comments .

Here you can see the number "62" - it means that out of all your pending posts and comments there are only 62 posts/comments which got atleast 1 upvote.

And wait for it to load everything and at the end you can see the Summary -

Things to note

  1. This is only for second layer tokens and not for Hive

  2. The Summary contains both author and curation rewards together .

  3. The convertion price to Hive is the latest token price.

I will try and improve this as and when I can . That's it for now . Will meet you tomorrow with another post .


Regards, MR.

Posted Using LeoFinance Beta