Ejemplo n.º 1
0
    async def curation(self, ctx, *, authorperm: str):

        show_all_voter = False

        all_posts = False
        t = PrettyTable([
            "Voter", "Voting time", "Vote", "Early vote loss", "Curation",
            "Performance"
        ])
        t.align = "l"
        index = 0

        index += 1
        comment = Comment(authorperm, steem_instance=self.stm)
        payout = None
        curation_rewards_SBD = comment.get_curation_rewards(
            pending_payout_SBD=True, pending_payout_value=payout)
        curation_rewards_SP = comment.get_curation_rewards(
            pending_payout_SBD=False, pending_payout_value=payout)
        rows = []
        sum_curation = [0, 0, 0, 0]
        max_curation = [0, 0, 0, 0, 0, 0]
        highest_vote = [0, 0, 0, 0, 0, 0]
        for vote in comment["active_votes"]:
            vote_SBD = self.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 = (
                    (comment.get_curation_penalty(vote_time=vote["time"])) *
                    vote_SBD)
                performance = (float(curation_SBD) / vote_SBD * 100)
            else:
                performance = 0
                penalty = 0
            vote_befor_min = ((
                (vote["time"]) - comment["created"]).total_seconds() / 60)
            sum_curation[0] += vote_SBD
            sum_curation[1] += penalty
            sum_curation[2] += float(curation_SP)
            sum_curation[3] += float(curation_SBD)
            row = [
                vote["voter"], vote_befor_min, vote_SBD, penalty,
                float(curation_SP), performance
            ]
            if row[-1] > max_curation[-1]:
                max_curation = 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 = []
        new_row2 = []
        voter = []
        voter2 = []

        voter = [""]
        voter2 = [""]
        for row in sortedList:
            if show_all_voter:
                if not all_posts:
                    voter = [row[0]]
                if all_posts:
                    new_row[0] = "%d. %s" % (index, comment.author)
                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])
                ])

                new_row = new_row2
        t.add_row(new_row2 + voter2 + ["", "", "", "", ""])
        if sum_curation[0] > 0:
            curation_sum_percentage = sum_curation[3] / sum_curation[0] * 100
        else:
            curation_sum_percentage = 0
        sum_line = new_row2 + voter2
        sum_line[-1] = "High. vote"

        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]),
            "%.3f SBD" % float(max_curation[3]),
            "%.3f SP" % (max_curation[4]),
            "%.1f %%" % (max_curation[5])
        ])
        sum_line[-1] = "Sum"
        t.add_row(sum_line + [
            "-",
            "%.3f SBD" % (sum_curation[0]),
            "%.3f SBD" % (sum_curation[1]),
            "%.3f SP" % (sum_curation[2]),
            "%.2f %%" % curation_sum_percentage
        ])
        response = "curation for %s\n" % (authorperm)
        response += t.get_string()
        await ctx.channel.send("```" + response + "```")
Ejemplo n.º 2
0
            if op["author"] in member_accounts and op["voter"] in accounts:
                authorperm=construct_authorperm(op["author"], op["permlink"])
                vote = Vote(op["voter"], authorperm=authorperm, steem_instance=stm)
                print("member %s upvoted with %d" % (op["author"], int(vote["rshares"])))
                member_data[op["author"]]["rewarded_rshares"] += int(vote["rshares"])
                member_data[op["author"]]["balance_rshares"] -= int(vote["rshares"])
                
                upvote_delay = member_data[op["author"]]["upvote_delay"]
                if upvote_delay is None:
                    upvote_delay = 300
                performance = 0
                c = Comment(authorperm, steem_instance=stm)
                
                try:
                    
                    curation_rewards_SBD = c.get_curation_rewards(pending_payout_SBD=True)
                    curation_SBD = curation_rewards_SBD["active_votes"][vote["voter"]]
                    if vote_SBD > 0:
                        performance = (float(curation_SBD) / vote_SBD * 100)
                    else:
                        performance = 0                    
                except:
                    performance = 0
                    curation_rewards_SBD = None
                    
                rshares = int(vote["rshares"])
                vote_SBD = stm.rshares_to_sbd(int(vote["rshares"]))

                best_performance = 0
                best_time_delay = 0
                for v in c.get_votes():