[Steembar] - Voting power and user reputation added

in #utopian-io7 years ago (edited)

35838986-140f2ad4-0abc-11e8-951e-e976280d679d (1).png

Steembar is a simple but useful widget for macOS. It let you get the price of the Steem and Steem backed dollars quickly without needing to go to another page.

New Features


As new features, I decided to add the voting power and the reputation of the user. Why? Because me as a user, I tend to go to Steemd to check my voting power. Now, I just need to open this widget on my navbar. In addition, I added the reputation next to the user to easily check this stat.

To give the reputation of the user I have to rewrite the implementation from the SteemJs API in python code. One of the challenge was to remember that by default in js, math.log is using base e while in python you need to explicitly tell the base of the logarithm.

def get_vp_rp(steemit_name):
    url = '{}get_accounts?names[]=%5B%22{}%22%5D'.format(API, steemit_name)
    data = fetch(url)[0]
    vp = data['voting_power']
    _reputation = data['reputation']
    _reputation = int(_reputation)

    rep = str(_reputation)
    neg = True if rep[0] == '-' else False
    rep = rep[1:] if neg else rep
    srt = rep
    leadingDigits = int(srt[0:4])
    log_n = log(leadingDigits / log(10), 2.71828)
    n  = len(srt) - 1
    out = n + (log_n - int(log_n))
    if isnan(out): out = 0
    out = max(out - 9, 0)

    out = (-1 * out) if neg else (1 * out)
    out = out * 9 + 25
    out = int(out)
    return [ceil(vp / 100), out]

Basically, this function is getting two values, the voting power and the reputation. The value for the reputation is parsed by using the implementation used in the steemjs library. This function returns a tuple that can be accessed by index.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Hey @jaysermendez 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!
  • Seems like you contribute quite often. AMAZING!

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

Thank you for the contribution. It has been approved.

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

@jaysermendez, I always try to support who contribute to open source project, upvote you.

And I am happy that you exist!

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.030
BTC 62311.03
ETH 2443.26
USDT 1.00
SBD 2.69