steemrewarding.com - trail voting added

in #utopian-io6 years ago (edited)


rewarding_batch2.png

Repository

https://github.com/holgern/steemrewarding

steemrewarding.com is a feature-rich automatic voting tool. It can be used to create voting rules at https://steemrewarding.com, when posting authority was given to the @rewarding account. I created a discord server for all topics regarding steemrewarding.com: discord invitation.

Bug fixes

The following bugs were fixed:

  • Checks and handling for the app field in post metadata improved
  • bug with max_pending_payout fixed (integer instead of real in the database)
  • max votes per week and day fixed (all votes were counted instead of the votes for the voter)

New features

Trail votes added

It is now possible to follow other voters. A new trail vote rule can be created at https://steemrewarding.com/new_trail_rule:
image.png

Stored trail vote rules are listed at: https://steemrewarding.com/show_trail_rules.

A trail vote rule must contain a voter to follow. Only one rule can be stored per voter. Creating a new rule for a voter that already exists, will overwrite the old rule for this voter.

Votes that fit to rule will be stored in the votes database (this is done in the stream_blocks.py script). Then, pending votes will be created based on stored trail rules, in the apply_trail_vote_rules.py. From here on, it is not distinguished between a normal pending vote or a trail pending vote. Both are stored in the pending vote database.

The meaning of the parameter is the following:

  • vote to follow - must not be empty and is the steem account name to follow
  • enabled - when checked (True) the vote is active
  • only_main_post - when checked (True), comments will be skipped
  • vote_weight_treshold [%] - skips votes with lower weight (e.g. when set to 10%, a vote with a weight of 1% is skipped)
  • vote_weight_scaler [%] - set the vote weight percentage in comparison to the vote to follow. when set to 100%, the casted vote will have the same vote weight. When set to 50%, the vote weigth is multiplied by 0.5.
  • vote_weight_offset [%] - is added after applying vote_weight_scaler. When vote_weight_scaler is set to 0%, the vote_weight_offset can be used to set a constant vote weight.
  • include_authors - when set, only the list of given authors will be voted. The authors must be separated by a comma or a space (e.g. a,b)
  • exclude_authors - when set, these authors will be skipped. The authors must be separated by a comma or a space (e.g. a,b)
  • include_tags - when set, only posts which have at least one tag from the list of given tags will be voted. The tags must be separated by a comma or a space (e.g. a,b)
  • exclude_tags- when set, only posts which do not have at one tag from the list of given tags will be voted. The tags must be separated by a comma or a space (e.g. a,b)
  • minimum_vote_delay_min [minutes] - vote is delayed when earlier
  • maximum_vote_delay_min [minutes] - vote is skipped when older
  • max_votes_per_day - limits the maximum number of votes given through steemrewarding
  • max_votes_per_week - limits the maximum number of votes given through steemrewarding
  • min_vp [%] - vote is skipped when vote power is below
  • vp_scaler- When greater than 0, it can be used to adapt the vote weight to the vote power. When set to 1, the vote weight is equal to the vote power ( vote weight = 100 - ((100-vp) *vp_scaler)).
  • exclude_declined_payout - When checked (True), a post/comment with declined payout is skipped
  • max_net_votes - when greater than -1, a post/comment is skipped when more than max_net_votes voters already have voted.
  • max_pending_payout - When greater than -1, a post/comment is skipped when the pending payout is greater than max_pending_payout

Refactoring

A login decorator function was added to the flask app:

def login(func):
    @wraps(func)
    def check_access_token(*args, **kwargs):
        access_token = request.args.get("access_token", None)
        if access_token is None and 'access_token' not in session:
            login_url = steemconnect.get_login_url(
                "https://steemrewarding.com/welcome",
            )        
            return render_template('please_login.html', login_url=login_url)
        elif access_token is None:
            access_token = session['access_token']
        else:
            session['access_token'] = access_token
        try:
          
            steemconnect.set_access_token(access_token)
            name = steemconnect.me()["name"]
        except:
            login_url = steemconnect.get_login_url(
                "https://steemrewarding.com/welcome",
            )        
            return render_template('please_login.html', login_url=login_url)        
        return func(*args, **kwargs)
    return check_access_token

By adding this decorator, all functions could be reduced. @login decorater assure that a valid token is stored in the session variable.

@app.route('/')
@login
def main():
    name = steemconnect.me()["name"]
    return render_template('welcome.html', user=name, rewardingversion=rewardingversion)

Commits

upload changed sql database

refacktor string splitting and show version on the website

commit 1a6b5ae

Add decorator to flask app in order to reduce duplicated code lines

Add trail vote interface to the website

trail voting handling added

  • commit 3c3f624
  • new trail_vote_rules database added
  • votes that belong to a trail vote rule are processed in apply_trail_vote_rules.py

Several improvments

  • commit 5d67397
  • New string_included and string_excluded utility function with unit tests for checking if apps or author are included or excluded
  • maximum_vote_delay_min added to pending vote and rule
  • try catch added to curation reward calculation
  • Checks and handling for the app field in post metadata improved
  • bug with max_pending_payout fixed (integer instead of real in the database)
  • max votes per week and day fixed (all votes were counted instead of the votes for the voter)
  • app field in comments changed to rewarding

GitHub Account

https://github.com/holgern

Sort:  
  • Good use of images, code samples & explanations of changes.
  • This piece of code repeats at least 4 times, perhaps some refactoring could help here as well,
    Screenshot from 2019-02-05 21-06-18.png
  • More comments in the code would be welcomed.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Thank you for your review, @helo! Keep up the good work!

Thank you so much for participating the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!

Thanks for the wonderful piece there.

Good to see the bug being fixed which i had reported and now all seem working very well to me. I was thinking about this feature but you have already implemented it. Indeed a needy and useful feature, mostly for communities.

Hi @holger80!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hi, @holger80!

You just got a 2.85% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.

This post has been included in the latest edition of SoS Daily News - a digest of all you need to know about the State of Steem.

Hello!

I am a community manager at Snax. We are trying to make public blockchain based on EOS node. Snax chain will provide transactions over social networks, token supply based on user social influence.

Snax as well as Steemit rewards its users for the content created, but Snax works as overlay solution over existing social networks (e.g. Twitter)

We have no ICO. We already have a testnet, mainnet will be launched this month, and we currently looking for great candidates for Block Producers like yourself. You can find out more about us at our website snax.one

If our project is interesting for you, please let me know by emailing me at [email protected]

Looking forward to hearing from you, and keep rocking this world!