Skip to content

Commit

Permalink
Fix and improve curation even more
Browse files Browse the repository at this point in the history
  • Loading branch information
holgern committed May 27, 2018
1 parent 10e449d commit 122e234
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 23 deletions.
40 changes: 27 additions & 13 deletions beem/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1760,15 +1760,19 @@ def votes(account, direction, outgoing, incoming, days, export):
@cli.command()
@click.argument('authorperm', nargs=1, required=False)
@click.option('--account', '-a', help='Show only curation for this account')
@click.option('--limit', '-l', help='Show only the first minutes')
@click.option('--limit', '-m', help='Show only the first minutes')
@click.option('--min-vote', '-v', help='Show only votes higher than the given value')
@click.option('--max-vote', '-w', help='Show only votes lower than the given value')
@click.option('--min-performance', '-x', help='Show only votes with performance higher than the given value')
@click.option('--max-performance', '-y', help='Show only votes with perfromance lower than the given value')
@click.option('--payout', default=None, help="Show the curation for a potential payout in SBD as float")
@click.option('--export', '-e', default=None, help="Export results to HTML-file")
@click.option('--short', '-s', is_flag=True, default=False, help="Show only Curation without sum")
@click.option('--length', '-l', help='Limits the permlink character length', default=None)
@click.option('--permlink', '-p', help='Show the permlink for each entry', is_flag=True, default=False)
@click.option('--title', '-t', help='Show the title for each entry', is_flag=True, default=False)
@click.option('--days', '-d', default=7., help="Limit shown rewards by this amount of days (default: 7), max is 7 days.")
def curation(authorperm, account, limit, payout, export, short, length, permlink, title, days):
def curation(authorperm, account, limit, min_vote, max_vote, min_performance, max_performance, payout, export, short, length, permlink, title, days):
""" Lists curation rewards of all votes for authorperm
When authorperm is empty or "all", the curation rewards
Expand Down Expand Up @@ -1838,13 +1842,13 @@ def curation(authorperm, account, limit, payout, export, short, length, permlink
rows = []
sum_curation = [0, 0, 0, 0]
max_curation = [0, 0, 0, 0, 0, 0]
max_vote = [0, 0, 0, 0, 0, 0]
highest_vote = [0, 0, 0, 0, 0, 0]
for vote in comment["active_votes"]:
vote_SBD = stm.rshares_to_sbd(int(vote["rshares"]))
curation_SBD = curation_rewards_SBD["active_votes"][vote["voter"]]
curation_SP = curation_rewards_SP["active_votes"][vote["voter"]]
if vote_SBD > 0:
penalty = ((100 - comment.get_curation_penalty(vote_time=vote["time"])) / 100 * vote_SBD)
penalty = ((comment.get_curation_penalty(vote_time=vote["time"])) * vote_SBD)
performance = (float(curation_SBD) / vote_SBD * 100)
else:
performance = 0
Expand All @@ -1862,8 +1866,8 @@ def curation(authorperm, account, limit, payout, export, short, length, permlink
performance]
if row[-1] > max_curation[-1]:
max_curation = row
if row[2] > max_vote[2]:
max_vote = row
if row[2] > highest_vote[2]:
highest_vote = row
rows.append(row)
sortedList = sorted(rows, key=lambda row: (row[1]), reverse=False)
new_row = []
Expand All @@ -1888,23 +1892,33 @@ def curation(authorperm, account, limit, payout, export, short, length, permlink
if not all_posts:
voter = [""]
voter2 = [""]

found_voter = False
for row in sortedList:
if limit is not None and row[1] > float(limit):
continue
if min_vote is not None and float(row[2]) < float(min_vote):
continue
if max_vote is not None and float(row[2]) > float(max_vote):
continue
if min_performance is not None and float(row[5]) < float(min_performance):
continue
if max_performance is not None and float(row[5]) > float(max_performance):
continue
if show_all_voter or account == row[0]:
if not all_posts:
voter = [row[0]]
if all_posts:
new_row[0] = "%d. %s" % (index, comment.author)
if not found_voter:
found_voter = True
t.add_row(new_row + voter + ["%.1f min" % row[1],
"%.3f SBD" % float(row[2]),
"%.3f SBD" % float(row[3]),
"%.3f SP" % (row[4]),
"%.1f %%" % (row[5])])
if len(authorperm_list) == 1:
new_row = new_row2
if not short:
if not short and found_voter:
t.add_row(new_row2 + voter2 + ["", "", "", "", ""])
if sum_curation[0] > 0:
curation_sum_percentage = sum_curation[3] / sum_curation[0] * 100
Expand All @@ -1913,11 +1927,11 @@ def curation(authorperm, account, limit, payout, export, short, length, permlink
sum_line = new_row2 + voter2
sum_line[-1] = "High. vote"

t.add_row(sum_line + ["%.1f min" % max_vote[1],
"%.3f SBD" % float(max_vote[2]),
"%.3f SBD" % float(max_vote[3]),
"%.3f SP" % (max_vote[4]),
"%.1f %%" % (max_vote[5])])
t.add_row(sum_line + ["%.1f min" % highest_vote[1],
"%.3f SBD" % float(highest_vote[2]),
"%.3f SBD" % float(highest_vote[3]),
"%.3f SP" % (highest_vote[4]),
"%.1f %%" % (highest_vote[5])])
sum_line[-1] = "High. Cur."
t.add_row(sum_line + ["%.1f min" % max_curation[1],
"%.3f SBD" % float(max_curation[2]),
Expand Down
2 changes: 1 addition & 1 deletion beem/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""THIS FILE IS GENERATED FROM beem SETUP.PY."""
version = '0.19.31'
version = '0.19.32'
5 changes: 0 additions & 5 deletions beem/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,6 @@ def getPrivateKeyForPublicKey(self, pub):
return Wallet.keys[pub]
else:
raise MissingKeyError("No private key for {} found".format(pub))
# elif len(Wallet.keys) == 1:
# If there is only one key in my overwrite-storage, then
# use that one! Whether it will has sufficient
# authorization is left to ensure by the developer
# return list(self.keys.values())[0]
else:
# Test if wallet exists
if not self.created():
Expand Down
2 changes: 1 addition & 1 deletion beemapi/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""THIS FILE IS GENERATED FROM beem SETUP.PY."""
version = '0.19.31'
version = '0.19.32'
2 changes: 1 addition & 1 deletion beembase/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""THIS FILE IS GENERATED FROM beem SETUP.PY."""
version = '0.19.31'
version = '0.19.32'
2 changes: 1 addition & 1 deletion beemgraphenebase/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""THIS FILE IS GENERATED FROM beem SETUP.PY."""
version = '0.19.31'
version = '0.19.32'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
ascii = codecs.lookup('ascii')
codecs.register(lambda name, enc=ascii: {True: enc}.get(name == 'mbcs'))

VERSION = '0.19.31'
VERSION = '0.19.32'

tests_require = ['mock >= 2.0.0', 'pytest', 'pytest-mock', 'parameterized']

Expand Down

0 comments on commit 122e234

Please sign in to comment.