create account

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

View this thread on: hive.blogpeakd.comecency.com
· @learnelectronics ·
$35.66
SteemAX 1.6 ~ Automatically Accept 1:1 Invites, Set Vote Power Threshold, Create Non-expiring Exchanges, Top Users Page
#### Repository
https://github.com/artolabs/steemax

<center>
![steemax_1.6_update.png](https://cdn.steemitimages.com/DQmTEYxJkVb3HotbSi57nEBmHXLAWVnMdcHBeyzW4k4oXee/steemax_1.6_update.png)
</center>

##### [SteemAX](https://steemax.trade) 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.

<center>
![settings.png](https://cdn.steemitimages.com/DQma99D3gmaMLckNHD9hM5J4iRSHzp3v8ALycQp3Jg9Gmw4/settings.png)
</center>

## 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](https://github.com/ArtoLabs/SteemAX/commit/c34873906a45f4df0f2143f3c742501d45a4070b)

## 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](https://github.com/ArtoLabs/SteemAX/commit/e6174919fa9cc3a58efd67e520058c3f73027a91)


## 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](https://github.com/ArtoLabs/SteemAX/commit/c34873906a45f4df0f2143f3c742501d45a4070b)

## [Top 100 Users Page](https://steemax.info/users)

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. 

<center>
![top_100.png](https://cdn.steemitimages.com/DQmRwZEZG8iKR4668K77T2Vnhtq2VJVMm1TLkD49EeLxepY/top_100.png)
</center>

#### 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](https://github.com/ArtoLabs/SteemAX/commit/70a2173c060503b63f4cda1d6a3c2b84a8a66794)

#### 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](https://steemax.info/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
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 56 others
properties (23)
authorlearnelectronics
permlinksteemax-1-6-automatically-accept-1-1-invites-set-vote-power-threshold-create-non-expiring-exchanges-top-users-page
categoryutopian-io
json_metadata{"tags":["utopian-io","development","steemax","steemit","python3"],"users":["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"],"image":["https://cdn.steemitimages.com/DQmTEYxJkVb3HotbSi57nEBmHXLAWVnMdcHBeyzW4k4oXee/steemax_1.6_update.png","https://cdn.steemitimages.com/DQma99D3gmaMLckNHD9hM5J4iRSHzp3v8ALycQp3Jg9Gmw4/settings.png","https://cdn.steemitimages.com/DQmRwZEZG8iKR4668K77T2Vnhtq2VJVMm1TLkD49EeLxepY/top_100.png"],"links":["https://github.com/artolabs/steemax","https://steemax.trade","https://github.com/ArtoLabs/SteemAX/commit/c34873906a45f4df0f2143f3c742501d45a4070b","https://github.com/ArtoLabs/SteemAX/commit/e6174919fa9cc3a58efd67e520058c3f73027a91","https://steemax.info/users","https://github.com/ArtoLabs/SteemAX/commit/70a2173c060503b63f4cda1d6a3c2b84a8a66794","https://steemax.info","https://discord.gg/97GKVFC","https://github.com/artolabs"],"app":"steemit/0.1","format":"markdown"}
created2019-01-04 16:37:54
last_update2019-01-04 16:37:54
depth0
children5
last_payout2019-01-11 16:37:54
cashout_time1969-12-31 23:59:59
total_payout_value27.017 HBD
curator_payout_value8.645 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length11,527
author_reputation15,479,971,201,369
root_title"SteemAX 1.6 ~ Automatically Accept 1:1 Invites, Set Vote Power Threshold, Create Non-expiring Exchanges, Top Users Page"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,871,580
net_rshares65,828,890,605,615
author_curate_reward""
vote details (120)
@artturtle ·
message
### Thank you learnelectronics! You've just received an upvote of 72% by @ArtTurtle!

<a href="https://steemit.com/art/@artopium/artturtle-will-upvote-each-and-every-one-of-your-art-music-posts">
<img src="https://steemitimages.com/0x0/https://cdn.steemitimages.com/DQmT74pZRACxgYK9JcfU3u22qLuJmUgSQsbwoPksykT8YGA/artturtlead.png"></a>

### [Learn how I will upvote each and every one of *your* art and music posts](https://steemit.com/art/@artopium/artturtle-will-upvote-each-and-every-one-of-your-art-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.
properties (22)
authorartturtle
permlinkre-steemax-1-6-automatically-accept-1-1-invites-set-vote-power-threshold-create-non-expiring-exchanges-top-users-page-20190104t170032
categoryutopian-io
json_metadata""
created2019-01-04 17:00:33
last_update2019-01-04 17:00:33
depth1
children0
last_payout2019-01-11 17:00:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length653
author_reputation18,796,114,672,508
root_title"SteemAX 1.6 ~ Automatically Accept 1:1 Invites, Set Vote Power Threshold, Create Non-expiring Exchanges, Top Users Page"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,872,575
net_rshares0
@helo ·
$12.66
- 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](https://join.utopian.io/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](https://review.utopian.io/result/3/1-3-1-1-2-1-2-).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , , , , , , , , , ,
properties (23)
authorhelo
permlinkre-learnelectronics-steemax-1-6-automatically-accept-1-1-invites-set-vote-power-threshold-create-non-expiring-exchanges-top-users-page-20190104t174312314z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://join.utopian.io/guidelines","https://review.utopian.io/result/3/1-3-1-1-2-1-2-","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2019-01-04 17:43:12
last_update2019-01-04 17:43:12
depth1
children1
last_payout2019-01-11 17:43:12
cashout_time1969-12-31 23:59:59
total_payout_value9.567 HBD
curator_payout_value3.089 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length595
author_reputation121,547,934,535,311
root_title"SteemAX 1.6 ~ Automatically Accept 1:1 Invites, Set Vote Power Threshold, Create Non-expiring Exchanges, Top Users Page"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,874,395
net_rshares23,391,511,253,317
author_curate_reward""
vote details (12)
@utopian-io ·
Thank you for your review, @helo! Keep up the good work!
properties (22)
authorutopian-io
permlinkre-re-learnelectronics-steemax-1-6-automatically-accept-1-1-invites-set-vote-power-threshold-create-non-expiring-exchanges-top-users-page-20190104t174312314z-20190107t010151z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2019-01-07 01:01:54
last_update2019-01-07 01:01:54
depth2
children0
last_payout2019-01-14 01:01:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length56
author_reputation152,955,367,999,756
root_title"SteemAX 1.6 ~ Automatically Accept 1:1 Invites, Set Vote Power Threshold, Create Non-expiring Exchanges, Top Users Page"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,990,287
net_rshares0
@steem-ua ·
#### 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](https://discord.gg/KpBNYGz)**
properties (22)
authorsteem-ua
permlinkre-steemax-1-6-automatically-accept-1-1-invites-set-vote-power-threshold-create-non-expiring-exchanges-top-users-page-20190104t174832z
categoryutopian-io
json_metadata"{"app": "beem/0.20.14"}"
created2019-01-04 17:48:33
last_update2019-01-04 17:48:33
depth1
children0
last_payout2019-01-11 17:48:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length295
author_reputation23,214,230,978,060
root_title"SteemAX 1.6 ~ Automatically Accept 1:1 Invites, Set Vote Power Threshold, Create Non-expiring Exchanges, Top Users Page"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,874,573
net_rshares0
@utopian-io ·
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](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

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

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-steemax-1-6-automatically-accept-1-1-invites-set-vote-power-threshold-create-non-expiring-exchanges-top-users-page-20190105t042751z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2019-01-05 04:27:51
last_update2019-01-05 04:27:51
depth1
children0
last_payout2019-01-12 04:27:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length598
author_reputation152,955,367,999,756
root_title"SteemAX 1.6 ~ Automatically Accept 1:1 Invites, Set Vote Power Threshold, Create Non-expiring Exchanges, Top Users Page"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id77,896,204
net_rshares0