The Daily Adventures of a SteemPeak Developer #8 - Show Scotbot Delay in the Tribes Page

in dailyadventures •  5 years ago  (edited)

A while back I've seen this post by @holger80 and soon I created a ticket for SteemPeak as a reminder to add these details to the Tribes page. I've been busy with other features but finally got to this ticket and included this feature in the next update.

The main reason to show this information is to inform users when Scotbot is a bit behind on blocks and rewards displayed may be not aligned yet.

Show the Scotbot delay in the Tribes page

the_daily_adventure_cover_scot_delay.png

Read other posts in the series HERE


As explained in the post I linked above the main API endpoint to retrieve the current state of the sidechain is https://scot-api.steem-engine.com/state. The response is the following:

{"last_backend_timestamp":"2019-07-25T11:56:20","last_streamed_block":34970211,"last_streamed_timestamp":"2019-07-25T11:56:03","time_delay_seconds":17.330111}

So I added a call to this API when the Tribes page is loaded and a check on the time_delay_seconds field to show a warning when the delay is greater than 5 minutes.

const scotNode = 'https://scot-api.steem-engine.com';

...

computed: {
  showWarning () {
    return this.scotDelayMinutes > 5;
  }
},

...

mounted () {
  axios.get(`${scotNode}/state`).then(response => {
    this.scotDelayMinutes = parseInt(response.data.time_delay_seconds / 60);
    this.scotStateDetails = response.data;
  }).catch(error => {
    console.error('Error retrieving SCOT state: ', error)
  })
}

...

When showWarning is equals to true a small label is shown with more details available in a tooltip (for this example I modified the code to always show the warning, despite the 5 minutes threshold):

Selection_087.png

I hope you will like this small addition but I'll be happy if you never see it as it means that Scotbot is doing great :D ...and of course a thank you to @holger80 for all his great work.


As always feedback and suggestion are much appreciated, both in the comments or on our Discord ;)


Sergio

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

It's the little things like this that make you amazing at what you do. From everyone at SteemPeak and using SteemPeak... thank you.

  ·  5 years ago Reveal Comment