[Dach-support] Not displaying accounts with negative reputation fix

in utopian-io •  7 months ago

image.png

This contribution is a solution to Not displaying accounts with reputation <25 via the "?info accountname" function!.
@theaustrianguy bug report directs DACH-Discord server bot by @jedigeiss.

What was the issue(s)?

According to bughunter, ?info accountname command didn't display any info for users with reputation under 25. This is not exactly true, because the issue was with accounts of reputation < 0.

Examples:

  • ?info berniesanders (-17) - no response
  • ?info dzordyja (-1) - no response

Why is that?

Traversing through the code, it threw error at line:
rep = math.log10(rep)
where rep is raw reputation stored in blockchain. It is very large (or very small) number. According to steemd.com for berniesanders it is value of -46,967,291,106,564.
The math rule says common logarithm cannot calculate negative input numbers. That's why ValueError: math domain error happens exiting whole call.

Steem official formula

Steemit.com FAQ relates to nice article with formula explanation.

  • Take the log base 10 of the raw score
  • Subtract 9
  • Multiply by 9
  • Add 25
  • Round down to the nearest integer

image.png

Code snippet by @digitalnotvir

What was the solution?

To keep things simple I have verified if raw reputation score is negative. Then calculated absolute value of it and logarithm of. Attached negative sign again to the result (if marked) and keep through rest of formula.

image.png

Formula for reputation level including negativeness

Links

https://github.com/jedigeiss/dach-support/pull/16



Posted on Utopian.io - Rewarding Open Source Contributors

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:  

Upvote

Thank you for the contribution. It has been approved.

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

·

Thanks a lot!

·

Hey @wehmoen, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

dear @mys
All your posts are good, which can be learned a lot,
thank you

Good post my friend @mys

Very good content