forkeado de spla/fediverse
Added top five project data
This commit is contained in:
pare
6905a56689
commit
67175424bb
S'han modificat 1 arxius amb 25 adicions i 8 eliminacions
33
fediverse.py
33
fediverse.py
|
@ -732,7 +732,7 @@ z = zip(world_servers)
|
|||
serv_number = len(world_servers)
|
||||
|
||||
pool_tuple = [(x, q) for x in z]
|
||||
with Pool(processes=64) as pool:
|
||||
with Pool(processes=32) as pool:
|
||||
pool.starmap(getserver, pool_tuple)
|
||||
|
||||
###########################################################################
|
||||
|
@ -763,9 +763,13 @@ finally:
|
|||
conn.close()
|
||||
|
||||
###########################################################################
|
||||
# get current total servers and users
|
||||
# get current total servers and users, get users from every software
|
||||
|
||||
select_sql = "select count(server), sum(users) from fediverse"
|
||||
gettotals_sql = "select count(server), sum(users) from fediverse"
|
||||
get_soft_totals_sql = "select software, sum(users) as users, count(server) as servers from fediverse where users != 0 group by software order by users desc"
|
||||
soft_total_project = []
|
||||
soft_total_users = []
|
||||
soft_total_servers = []
|
||||
|
||||
try:
|
||||
|
||||
|
@ -774,13 +778,19 @@ try:
|
|||
|
||||
cur = conn.cursor()
|
||||
|
||||
cur.execute(select_sql)
|
||||
cur.execute(gettotals_sql)
|
||||
|
||||
row = cur.fetchone()
|
||||
|
||||
total_servers = row[0]
|
||||
total_users = row[1]
|
||||
|
||||
cur.execute(get_soft_totals_sql)
|
||||
rows = cur.fetchall()
|
||||
for row in rows:
|
||||
soft_total_project.append(row[0])
|
||||
soft_total_users.append(row[1])
|
||||
soft_total_servers.append(row[2])
|
||||
cur.close()
|
||||
|
||||
except (Exception, psycopg2.DatabaseError) as error:
|
||||
|
@ -794,7 +804,7 @@ finally:
|
|||
conn.close()
|
||||
|
||||
###########################################################################
|
||||
# get last check values and write current total values
|
||||
# get last check values and write current total ones
|
||||
|
||||
select_sql = "select total_servers, total_users from totals order by datetime desc limit 1"
|
||||
insert_sql = "INSERT INTO totals(datetime, total_servers, total_users) VALUES(%s,%s,%s)"
|
||||
|
@ -908,13 +918,20 @@ if evo_servers >= 0:
|
|||
elif evo_servers < 0:
|
||||
toot_text += "alive servers: " + str(total_servers) + " (-"+ str(evo_servers) + ") \n"
|
||||
if evo_users >= 0:
|
||||
toot_text += "total Users: " + str(total_users) + " (+"+ str(evo_users) + ") \n"
|
||||
toot_text += "total users: " + str(total_users) + " (+"+ str(evo_users) + ") \n"
|
||||
elif evo_users < 0:
|
||||
toot_text += "total Users: " + str(total_users) + " (-"+ str(evo_users) + ") \n"
|
||||
toot_text += "total users: " + str(total_users) + " (-"+ str(evo_users) + ") \n"
|
||||
toot_text += "\n"
|
||||
toot_text += "top five (soft: users servers):" + " \n"
|
||||
toot_text += "\n"
|
||||
toot_text += '{:>0}: {:>5} {:>5}'.format(str(soft_total_project[0]), str(soft_total_users[0]), str(soft_total_servers[0])) + " \n"
|
||||
toot_text += '{:>0}: {:>11} {:>8}'.format(str(soft_total_project[1]), str(soft_total_users[1]), str(soft_total_servers[1])) + " \n"
|
||||
toot_text += '{:>0}: {:>12} {:>7}'.format(str(soft_total_project[2]), str(soft_total_users[2]), str(soft_total_servers[2])) + " \n"
|
||||
toot_text += '{:>0}: {:>13} {:>7}'.format(str(soft_total_project[3]), str(soft_total_users[3]), str(soft_total_servers[3])) + " \n"
|
||||
toot_text += '{:>0}: {:>14} {:>7}'.format(str(soft_total_project[4]), str(soft_total_users[4]), str(soft_total_servers[4])) + " \n"
|
||||
toot_text += "\n"
|
||||
toot_text += "updated at " + str(last_update) + " \n"
|
||||
print("Tooting...")
|
||||
print(toot_text)
|
||||
|
||||
mastodon.status_post(toot_text, in_reply_to_id=None, )
|
||||
|
||||
|
|
Loading…
Referencia en una nova incidència