Skip to content
Permalink
Browse files

Add pause votes when below a global VP threshold to settings

  • Loading branch information...
holgern committed May 27, 2019
1 parent 897265f commit 8c5d628e619f5574c2801fc0a88bc739e912de7d
Showing with 25 additions and 4 deletions.
  1. +3 −1 homepage/app.py
  2. +1 −0 homepage/templates/settings.html
  3. +21 −3 upvote_post_comments.py
@@ -257,6 +257,7 @@ class SettingsForm(FlaskForm):
rshares_divider = FloatField('rshares_divider (Defines the lower limit of rshares that are considered for curaiton optimization, vote_rshares > own_votershares / rshares_divider)', default=5)
frontend = TextAreaField('Frontend-URL', default="https://steemit.com/")
sliding_time_window = BooleanField('sliding_time_window (When true, votes for max_votes_per_day are counting for the last 24 hours, When False, votes for max_votes_per_day are counted from 0:0:0 UTC, some is done for max_votes_per_week)', default=True)
pause_votes_below_vp = FloatField('Pause all votes when Vote power is below this value.', default=0.0)


class VoteForm(FlaskForm):
@@ -485,7 +486,7 @@ def settings_dict_from_form(account, form):
"minimum_vote_delay": form.minimum_vote_delay.data, "maximum_vote_delay": form.maximum_vote_delay.data,
"optimize_ma_length": form.optimize_ma_length.data, "optimize_threshold": form.optimize_threshold.data,
"rshares_divider": form.rshares_divider.data, "frontend": form.frontend.data, "sliding_time_window": form.sliding_time_window.data,
"optimize_vote_delay_slope": form.optimize_vote_delay_slope.data}
"optimize_vote_delay_slope": form.optimize_vote_delay_slope.data, "pause_votes_below_vp": form.pause_votes_below_vp.data}
return settings

def login(func):
@@ -1264,6 +1265,7 @@ def settings():
form.frontend.data = setting["frontend"]
form.sliding_time_window.data = setting["sliding_time_window"]
form.optimize_vote_delay_slope.data = setting["optimize_vote_delay_slope"]
form.pause_votes_below_vp.data = setting["pause_votes_below_vp"]
return render_template('settings.html', form=form, user=name)


@@ -23,6 +23,7 @@ <h3 class="card-title text-center">Settings for {{ user }} </h3>
{{ render_field(form.rshares_divider) }}
{{ render_field(form.frontend) }}
{{ render_field(form.sliding_time_window) }}
{{ render_field(form.pause_votes_below_vp) }}


</dl>
@@ -164,8 +164,10 @@
settings = accountsTrx.get(voter_acc["name"])
if settings is not None:
sliding_time_window = settings["sliding_time_window"]
pause_votes_below_vp = settings["pause_votes_below_vp"]
else:
sliding_time_window = True
pause_votes_below_vp = 0
votes_24h_before = voteLogTrx.get_votes_per_day(pending_vote["voter"], author, sliding_time_window)
if votes_24h_before >= pending_vote["max_votes_per_day"]:
failedVoteLogTrx.add({"authorperm": pending_vote["authorperm"], "voter": pending_vote["voter"], "error": "The author was already upvoted %d in the last 24h (max_votes_per_day is %d)." % (votes_24h_before, pending_vote["max_votes_per_day"]),
@@ -198,7 +200,14 @@
"min_vp": pending_vote["min_vp"], "vp": voter_acc.vp, "vote_when_vp_reached": pending_vote["vote_when_vp_reached"],
"main_post": pending_vote["main_post"]})
delete_pending_votes.append({"authorperm": pending_vote["authorperm"], "voter": pending_vote["voter"], "vote_when_vp_reached": pending_vote["vote_when_vp_reached"]})
continue
continue
if voter_acc.vp < pause_votes_below_vp:
failedVoteLogTrx.add({"authorperm": pending_vote["authorperm"], "voter": pending_vote["voter"], "error": "Voting is paused (VP = %.2f %%, which below pause_votes_below_vp of %.2f %%)" % (voter_acc.vp, pause_votes_below_vp),
"timestamp": datetime.utcnow(), "vote_weight": vote_weight, "vote_delay_min": pending_vote["vote_delay_min"],
"min_vp": pending_vote["min_vp"], "vp": voter_acc.vp, "vote_when_vp_reached": pending_vote["vote_when_vp_reached"],
"main_post": pending_vote["main_post"]})
delete_pending_votes.append({"authorperm": pending_vote["authorperm"], "voter": pending_vote["voter"], "vote_when_vp_reached": pending_vote["vote_when_vp_reached"]})
continue
posting_auth = False
for a in voter_acc["posting"]["account_auths"]:
if a[0] == posting_auth_acc:
@@ -296,7 +305,16 @@
continue
if age_min < pending_vote["vote_delay_min"] - voting_round_sec / 2.0 / 60:
continue


if settings is None:
settings = accountsTrx.get(voter_acc["name"])
if settings is not None:
pause_votes_below_vp = settings["pause_votes_below_vp"]
else:
pause_votes_below_vp = 0
if voter_acc.vp < pause_votes_below_vp:
continue

vote_weight = pending_vote["vote_weight"]
if vote_weight <= 0:
vote_weight = voter_acc.get_vote_pct_for_SBD(float(pending_vote["vote_sbd"])) / 100.
@@ -347,7 +365,7 @@
if settings is None:
settings = accountsTrx.get(voter_acc["name"])
if settings is not None:
sliding_time_window = settings["sliding_time_window"]
sliding_time_window = settings["sliding_time_window"]
else:
sliding_time_window = True
votes_24h_before = voteLogTrx.get_votes_per_day(pending_vote["voter"], author, sliding_time_window)

0 comments on commit 8c5d628

Please sign in to comment.
You can’t perform that action at this time.