SteemAX 1.6 ~ Automatically Accept 1:1 Invites, Set Vote Power Threshold, Create Non-expiring Exchanges, Top Users Page

in utopian-io •  2 months ago

Repository

https://github.com/artolabs/steemax


steemax_1.6_update.png

SteemAX helps minnow content-creators and whale curators

by automating an exchange of upvotes between their quality blog posts, allowing both 1 to 1 as well as disproportional exchanges that grant bigger curations, better support than a bid bot, and the long-term support they both deserve.

Account Settings

SteemAX now provides users with the ability to save certain account settings that make using SteemAX more efficient and easier to use. When users log into SteemAX they will now see two new options below the invite creation form. This is the "Auto Accept 1:1 Invites" option and the "Vote Power Threshold" setting.

To save either of these settings a user must log into SteemAX create a new invite. The settings can be changed each time a new invite is created.


settings.png

Automatically Accept 1:1 Invites

Users now have the ability to automatically accept an invite that is set to a ratio of 1:1. To enable this they simply log in to the invite creation form and check the checkbox that says "Auto accept 1:1 invites" when creating an invite.

Anybody that sends an invite to a user that has enabled this feature and at the ratio of 1:1 will immediately receive a reply message that the exchange has been accepted and that the exchange will begin immediately.

To accomplish this:

First, a new column was added to the users database table.

AutoAccept varchar(5) DEFAULT "0"

A new function was added to axdb.py that fetches the value in the users table and returns true of that user has enabled Auto Accept.

    def auto_accept(self, acct):
        """ Determines if auto accept is on or off
        """
        if self.get_results('SELECT AutoAccept FROM users'
                            + ' WHERE Account = %s;',
                            acct):
            if self.dbresults[0][0] == "1":
                return True
            else:
                return False
        else:
            return False

Another function was created to fetch the ratio of the invite so that it can be ensured that is is indeed 1:1. Perhaps in a future release of SteemAX this can be adjusted.

    def get_ratio(self, memoid):
        """ Gets the ratio of an invite. This is necessary
      for the invite auto accept feature.
        """
        if self.get_results('SELECT Ratio '
                            + 'FROM axlist WHERE MemoID = %s;',
                            memoid):
            return self.dbresults[0][0]
        else:
            return False

When the user saves their settings there are placed into the database table with this function.

    def set_settings(self, acct, autoaccept, threshold):
        """ Sets the auto accept feature to on or off.
        """
        if float(autoaccept) != 1: 
            autoaccept = "0"
        if int(threshold) > 100 or int(threshold) < 0:
            threshold = "80"
        if self.commit('UPDATE users SET AutoAccept = %s, Threshold = %s'
                            + ' WHERE Account = %s;',
                            autoaccept, threshold, acct):
            return True
        else:
            return False

Finally, an if statement was added to the Reaction class in axtrans.py that handles the invite and automatically accepts it.

        # if the rstatus is -1 then the exchange invite has been
        # created in the database but not yet sent to the invitee.
        if self.db.auto_accept(acct2) is True and int(ratio) == 1 and rstatus < 0:
            # The accept message is sent "automatically"
        # "refund" in this case means send it back to sender
            self.accepted_msg(acct2, memoid)
            self.reaction = "refund"

Commit

Set Vote Power Threshold

Another option that can now be saved is the "Vote Power Threshold." When the Vote Power Threshold is exceeded exchanges will temporarily halt until the user's vote power has returned to above the threshold setting. This can be set in the same way as the auto accept invites: simply log into the invite creation form then under "Settings" change the value for the threshold when creating a new invite.

Having a vote power threshold is a necessary feature in order for non-expiring invites to not adversely affect vote power and resource credits.

NOTE: All current members of SteemAX have been set to a default threshold of 80%.

To accomplish this:

The set_settings function is already mentioned above. Besides setting the auto accept feature is saves the threshold setting as well. A function was also created in axdb.py to fethc the threshold value from the database:

    def threshold(self, acct):
        """ Returns the threshold value for votepower
        """
        if self.get_results('SELECT Threshold FROM users'
                            + ' WHERE Account = %s;',
                            acct):
            return self.dbresults[0][0]
        else:
            return False

The eligible_votes function in the Axverify class was updated to include these if states excluding accounts that have vote power values that have fallen below their threshold setting.

v1 = self.get_vote_value(account1, percentage, vpow)
        threshold = db.threshold(account1)
        if int(self.steem.vpow) < int(threshold):
            self.msg.message(account1 + " has a vote power of " 
                            + str(self.steem.vpow) 
                            + " which is below their threshold of " 
                            + threshold)
            return False
        v2 = self.get_vote_value(account2, 100, vpow)
        threshold = db.threshold(account2)
        if int(self.steem.vpow) < int(threshold):
            self.msg.message(account2 + " has a vote power of " 
                            + str(self.steem.vpow) 
                            + " which is below their threshold of " 
                            + threshold)
            return False

Commit

Create Non-expiring Exchanges

Users can now create invites to exchanges that do not expire, making the maintenance of their account much more manageable and efficient. The ability to create expiring exchanges still exists, and a user simply needs to choose this from the "Exchange Duration" drop down box on the invite creation form.

To accomplish this:

When the expire function is run is checks to see if the duration is larger than zero. If not it's a non-expiring exchange and is skipped.

    if (datetime.strptime(str(row[2]), '%Y-%m-%d %H:%M:%S')
        + timedelta(days=int(row[1])) < datetime.now()) and int(row[1]) > 0:
            self.commit("UPDATE axlist SET Status = 4 WHERE ID = %s;", row[0])
            self.msg.message(row[3] + " vs. " + row[4] + " has expired.")

Commit

Top 100 Users Page

Now visitors can see a list of the top 100 users of SteemAX. This is ordered by the total number of exchange invites created by that user (not necessarily the active exchanges). Visitors can also see whether one of these top 100 users automatically accepts 1:1 invites. This can help newcomers to SteemAX find people to immediately begin exchanges with.


top_100.png

To accomplish this:

The function get_users was added to axdb.py that fetches the top 100 users based on total exchanges created.

    def get_users(self):
        """ Returns a list of top 100 users
        """
        if self.get_results('SELECT users.Account, users.AutoAccept, users.Time, '
                            + 'a.Total + b.Total AS TheTotal '
                            + 'FROM users LEFT JOIN '
                            + '(SELECT Account1, COUNT(*) AS Total '
                            + 'FROM axlist GROUP BY Account1) AS a '
                            + 'ON users.Account = a.Account1 '
                            + 'LEFT JOIN (SELECT Account2, COUNT(*) AS Total '
                            + 'FROM axlist GROUP BY Account2) AS b '
                            + 'ON users.Account = b.Account2 '
                            + 'WHERE 1 ORDER BY TheTotal DESC LIMIT 100;'):
            return self.dbresults
        else:
            return False

Another function, users_page was added to web.py to display the list.

    def users_page(self):
        """ Creates a page that displays the top 100 users
        """
        users = self.db.get_users()
        boxtemplate = self.load_template("templates/userbox.html")
        userbox = ""
        for user in users:
            autoaccept = "No"
            if int(user[1]) == 1:
                autoaccept = "Yes"
            box = self.make_page(boxtemplate,
                                ACCOUNT=user[0],
                                AUTOACCEPT=autoaccept,
                                TOTAL=user[3])
            userbox = userbox + box
        pagetemplate = self.load_template("templates/user.html")
        return ("\r\n" + self.make_page(pagetemplate, 
                                    USERBOX=userbox))

Commit

Technology Stack

SteemAX is written to use Python 3.5 and MySQL. The web interface for https://steemax.trade and https://steemax.info has been written in HTML, CSS and Javascript.

Roadmap

In the future more contributors will be brought into the fold
via Task Requests to help improve the functionality of the site and most especially the look and feel. After all, projects always benefit from the synergistic action of teamwork.

Contact

Please contact Mike (Mike-A) on Discord
https://discord.gg/97GKVFC

GitHub Account

https://github.com/artolabs

Thank You To The Top Users of SteemAX!

@mmmmkkkk311, @apoloo1, @davedickeyyall, @shaman-ra, @jecminek, @annaabi, @gungunkrishu, @jozef230, @camiloferrua, @alexworld, @manicesoteric, @artturtle, @onealfa, @kryptomario, @slutwife, @eddiespino, @adeljose, @wdougwatson, @bearbear613, @lilixblack, @werpoli, @sipahikara, @johngreenfield, @kargul09, @amosbastian, @ookamisuuhaisha, @travelnepal, @genievot, @robb-27, @arena11, @voteyourcrypto, @mariuszkarowski, @ganeshkadam9503, @ajayyy, @joechiappetta, @adrimonte, @brosol, @cyrusik, @momzillanc, @miriamslozberg, @laritheghost, @flash07, @jaff8, @browery, @lenonmc21, @felipejoys, @bethvalverde, @mcoinz79, @zumerret, @tomfw, @a0i, @derekrichardson, @steemitgeek, @maxofp2p, @shawnalchemi, @flashcards, @eii, @gilabola.mania, @kara65, @nazaretprime, @outwork, @andrejcibik, @pataty69, @baro89, @frankremmy, @steemit-legacies, @kamilason, @steveconnor, @mizej, @mrplokmi, @ziqifuady, @jason04, @alpayasteem, @primeradue, @bliki, @aneilpatel, @usman93, @fredfred, @robertpayne114, @solocult, @shookriya, @hoodsly, @maerod, @krasnalek, @mohammad12

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:  
  • Very good post, good balance of code samples, explanations and images.
  • Keep up the good work.

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? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

·

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

Thank you learnelectronics! You've just received an upvote of 72% by @ArtTurtle!


Learn how I will upvote each and every one of your art and music posts

Please come visit me as I've updated my daily report with more information about my upvote value and how to get the best upvote from me.

Hi @learnelectronics!

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

Hey, @learnelectronics!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!