Asynchronous function call problem in SteemBotAnalysis

in #utopian-io7 years ago (edited)

Details

utopian link
github link
SteemBotAnalysis is using two main calls to steemdb with steem.js to read data.

API calls
  1. image.png
    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
    image.png
    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.
  2. image.png
    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
image.png
. Visually control if the data writing to innrHTML is finished.
. As it finishes push another button to calculate.
image.png
. Read from innerHTML all the data and put them in array
image.png
. Process the data with normal for-next loop since it is now synch. function.
image.png

To-do

  1. 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.
  2. 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 :

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

Sort:  

Thank you for the contribution. It has been approved.

  • Please add a license to the repo.
  • Consider making small commits to the repo instead of full file delete and uploads.

You can contact us on Discord.
[utopian-moderator]

Thank you for your approval.

  • The licence (MIT) is added to the repo.
  • Your recommendation is noted on commits.

FD.

Hey, I might be able to help. How does this work? New to Steem / Utopian.

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.

  1. You press contribution button and choose development category.
  2. Follow the guidelines and explain the contribution in details.
  3. You give the github referance of main project:https://github.com/firedreamgames/steembotanalysis
  4. You give referance to task request : https://utopian.io/utopian-io/@firedream/asynchronous-function-call-problem-in-steembotanalysis

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

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • You are generating more rewards than average for this category. Super!;)
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

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

Coin Marketplace

STEEM 0.18
TRX 0.15
JST 0.029
BTC 60775.02
ETH 2656.41
USDT 1.00
SBD 2.42