Not responding servers will keep included during 30 more days to not loose their MAU value

This commit is contained in:
spla 2023-01-11 13:07:59 +01:00
pare 6a877e6e46
commit b62782e519
S'han modificat 2 arxius amb 21 adicions i 9 eliminacions

Veure arxiu

@ -312,7 +312,7 @@ class Database():
conn.close() conn.close()
def write_not_alive_server(self, server, software, soft_version, alive, api, users, downs, first_checked_at): def write_not_alive_server(self, server, software, soft_version, alive, api, users, downs, first_checked_at, mau):
now = datetime.now() now = datetime.now()
@ -326,11 +326,11 @@ class Database():
if first_checked_at != None: if first_checked_at != None:
cur.execute("UPDATE fediverse SET updated_at=(%s), alive=(%s), downs=(%s) where server=(%s)", (now, alive, downs, server)) cur.execute("UPDATE fediverse SET updated_at=(%s), alive=(%s), downs=(%s), mau=(%s) where server=(%s)", (now, alive, downs, mau, server))
else: else:
cur.execute("UPDATE fediverse SET updated_at=(%s), alive=(%s), first_checked_at=(%s), downs=(%s) where server=(%s)", (now, alive, now, downs, server)) cur.execute("UPDATE fediverse SET updated_at=(%s), alive=(%s), first_checked_at=(%s), downs=(%s), mau=(%s) where server=(%s)", (now, alive, now, downs, mau, server))
cur.execute("UPDATE world SET checked='f' where server=(%s)", (server,)) cur.execute("UPDATE world SET checked='f' where server=(%s)", (server,))
@ -699,6 +699,7 @@ class Database():
soft_version = None soft_version = None
first_checked_at = None first_checked_at = None
downs_qty = None downs_qty = None
mau = 0
try: try:
@ -708,7 +709,7 @@ class Database():
cur = conn.cursor() cur = conn.cursor()
cur.execute("select alive, software, users_api, version, first_checked_at, downs from fediverse where server=(%s)", (server,)) cur.execute("select alive, software, users_api, version, first_checked_at, downs, mau from fediverse where server=(%s)", (server,))
row = cur.fetchone() row = cur.fetchone()
@ -720,6 +721,7 @@ class Database():
soft_version = row[3] soft_version = row[3]
first_checked_at = row[4] first_checked_at = row[4]
downs_qty = row[5] downs_qty = row[5]
mau = row[6]
cur.close() cur.close()
@ -733,7 +735,7 @@ class Database():
conn.close() conn.close()
return (was_alive, software, api, soft_version, first_checked_at, downs_qty) return (was_alive, software, api, soft_version, first_checked_at, downs_qty, mau)
def get_soft_data(self, search_soft): def get_soft_data(self, search_soft):

Veure arxiu

@ -48,7 +48,7 @@ class Server:
downs = 0 downs = 0
was_alive, software, api, soft_version, first_checked_at, downs_qty = db.get_server_data(self) was_alive, software, api, soft_version, first_checked_at, downs_qty, mau = db.get_server_data(self)
alive = False alive = False
@ -181,8 +181,6 @@ class Server:
if not alive: if not alive:
mau = 0
if downs_qty != None: if downs_qty != None:
downs = downs_qty + 1 downs = downs_qty + 1
@ -191,7 +189,19 @@ class Server:
downs = 1 downs = 1
db.write_not_alive_server(self, software, soft_version, alive, api, users, downs, first_checked_at) if downs_qty > 60 and not was_alive:
db.write_not_alive_server(self, software, soft_version, alive, api, users, downs, first_checked_at, mau)
elif downs_qty < 60 and not was_alive:
db.write_not_alive_server(self, software, soft_version, alive, api, users, downs, first_checked_at, mau)
elif downs_qty < 60 and was_alive:
alive = True
db.write_alive_server(self, software, soft_version, alive, api, users, downs, first_checked_at, mau)
return (self, software, soft_version, alive, api, users, downs, first_checked_at, mau) return (self, software, soft_version, alive, api, users, downs, first_checked_at, mau)