Added user values

This commit is contained in:
spla 2023-07-10 11:58:17 +02:00
pare ebaf28cd80
commit bcb5389a4a
S'han modificat 2 arxius amb 21 adicions i 4 eliminacions

Veure arxiu

@ -31,6 +31,8 @@ class Database():
topten_versions = []
topten_users = []
try:
conn = None
@ -39,7 +41,7 @@ class Database():
cur = conn.cursor()
cur.execute("select count(version), version from mau where software='mastodon' and alive group by version order by count(version) desc limit 10")
cur.execute("select count(version), version, sum(users) from mau where software='mastodon' and alive group by version order by count(version) desc limit 10")
rows = cur.fetchall()
@ -49,12 +51,20 @@ class Database():
topten_versions.append(row[1])
topten_users.append(row[2])
cur.execute("select count(version) from mau where software='mastodon' and alive")
row = cur.fetchone()
mast_servers = row[0]
cur.execute ("select sum(users) from mau where software='mastodon' and alive")
row = cur.fetchone()
mast_users = row[0]
cur.close()
except (Exception, psycopg2.DatabaseError) as error:
@ -67,7 +77,7 @@ class Database():
conn.close()
return (topten_servers, topten_versions, mast_servers)
return (topten_servers, topten_versions, topten_users, mast_servers, mast_users)
@staticmethod
def __check_dbsetup(self):

Veure arxiu

@ -15,17 +15,24 @@ if __name__ == '__main__':
api_base_url= setup.mastodon_hostname
)
topten_servers, topten_versions, mast_servers = db.get_versions()
topten_servers, topten_versions, topten_users, mast_servers, mast_users = db.get_versions()
toot_text = f'\nTotal alive Mastodon servers: {str(mast_servers)}\n\n'
toot_text += f'Top ten most used Mastodon versions: \n\n'
toot_text += f'version, servers, users\n\n'
i = 0
while i < 10:
toot_text += f'{str(i+1)} - v{topten_versions[i]} -> {str(topten_servers[i])} ({str(round(((topten_servers[i] * 100) / mast_servers), 2))}%)\n'
servers = '{0:,}'.format((topten_servers[i]))
users = '{0:,}'.format((topten_users[i]))
toot_text += f'v{topten_versions[i]}, {servers} ({str(round(((topten_servers[i] * 100) / mast_servers), 2))}%), {users} ({str(round(((topten_users[i] * 100) / mast_users), 2))}%)\n'
i += 1
toot_text += '\n#Mastodon'