Asynchronous function call problem in SteemBotAnalysis
Details
utopian link
github link
SteemBotAnalysis is using two main calls to steemdb with steem.js to read data.
API calls
Here there is no problem. We read the complete result array and can get the result.authperm variable as an array.
Then the authperm variable is splitted into author and permlink arrays with
which means our ap[n][0] array contains n'th author name and ap[n][1] array contains n'th permlink.
Also, you can get the array of upvote times with result[n].time which gives you the upvote time of n'th autperm.
This is where things get complicated.
This call is used to get the post date.
It requests the author and permlink to search.
This means, we have to for a loop (for-next, while etc..) to send each author + permlink to the function and request result from steemdb.
This doesn't function with the conventional loop because once the connection is not assured you get a null array as return.
The call is asynchronous.
Components
In the working project, the problem is solved manually.
. Read the steem data with the loop
. Write the data read to innerHTML
. Visually control if the data writing to innrHTML is finished.
. As it finishes push another button to calculate.
. Read from innerHTML all the data and put them in array
. Process the data with normal for-next loop since it is now synch. function.
To-do
- Find a process to eliminate the visual check and eliminate the calculate button.
Define global arrays for
. author
. permlink
. upvote time
. post time
and make sure these are accesable and complete to be processed from other functions. - Find a method for visually show the connection status, warn the user if connection not established.
Deadline
No deadline proposed.
Communication
You can contact me from :
- Discord : @firedream
- SteemIt : @firedream
- utopian.io: @firedream
Credits and Advice
for more information on steem.js I strongly recommend to check @stoodkev's tutorials at https://utopian.io/@stoodkev
Thank you very much for any contrubution.
FD.
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Thank you for your approval.
FD.
Hey, I might be able to help. How does this work? New to Steem / Utopian.
Go to utopian.io and make a contrubition to
https://utopian.io/utopian-io/@firedream/asynchronous-function-call-problem-in-steembotanalysis
Thank you.
PR sent! :)
Wow...It is working perfectly fast...
This is something I could not do and you got to teach me this bluebird sometime...
And I agree, node.js can be a perfect solution. I will open a second task request for this.
There is one major issue to be fixed...
I think the arrays do not reset when the start button is pressed again.
When you change the name or date, it pushes the new data on the old one and on div you see old results + new added ones.
This will be a minor fix I guess.
Can you do it ?
FD.
Good catch! Pushed a fix.
Perfect...it is working all fine. Now you have to make a contrubituon on utopian.io.
Explaining the project and following the utopian.io guidelines.
Then a mod will approve you contribution and utopian bot will reward you.
Generally 24-48 hours for mod approval and another 24-48 hours for utopian bot upvote.
Update : I have taken information from @mkt (supervisor) on how to make the contribution.
Rest, you wait for the mod approval.
Thank you very much.
FD.
how can I contact you ? need some advice...
Hey @firedream I am @utopian-io. I have just upvoted you!
Achievements
Suggestions
Get Noticed!
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x