Hello Utopians! @cryptouru over here with my second contribution :)
This time I come with a Voting bot and a SMT token tracker for the @actifit community (a community you should totally check out BTW). This development is a direct response of this task:
Before going into task details I want to thank @mcfarhat for the opportunity and say that it was a pleasure working with him and very nice to meet him. He really knows what he wants and how to communicate it, working with him was a breeze and we always seemed to be on the same page. I would totally repeat this experience :)
https://github.com/mcfarhat/actifit-bot
I divided the task into three separate node processes. The voting process, the token calculation process and an API process.
The voting process is heavily based on @yabapmatt community bot script:
https://github.com/MattyIce/communitybot
As the task requested this process does the following:
Besides the previous logic I added configuration options to exclude posts with paid votes from voting round and to set a minimum post age as filter. Paid votes filtering is done by consulting the steembottracker API to load an array of bots. (thanks again @yabapmatt !)
The main technologies involved on this task were:
Calculating token balances was no easy feat. My first approach was getDiscussionsByCreated a well known steemJS API method to bring new posts with the capability of filtering them by a tag.
When results were = 100 I made another request until results was <> 100 or the last post from the request was the same post used to index.
On paper this approach should have eventually loaded all actifit posts, yet there is an unspoken API limitation in regards unpopular tags, that is that you usually can't go more than a week back when using this method. I haven't found this documented anywhere, yet from experience I can say it is the case for many tags.
After hitting this wall I decided to go after the @actifit voting history.
@mcfarhat told me that it should include all posts elegible for token rewards. This approach was harder and more tedious but eventually brought all the posts we expected.
After the previous was running the process was as it follows:
user_tokens: with fields user, total_token_count
token_transactions: with fields user, reward_activity, post_permalink, date, and token_count.
In paralel there is a process which queries the token_transactions table and groups token counts with users. With this the user_tokens table/collection is filled
As a bonus I did setup the script to backup all post data that passes the filter, as I find this safe-guard to be good in the case or unexpected API limitations.
The main technologies involved int this task were:
Well... This is just 20 < lines of code Express API that queries the previous implementation.
It has two methods:
The main technologies involved int this task were:
I'm sort of an email guy, so I could not help but to implement an email notifications system. In case of an error, the configured email would get notified and after each voting round an e-mail summary would be sent.
I think that's all of it :)
If anyone has any doubt or concern just let me know. I'll hapilly reply.
Here's the pull request: