Not responding servers will keep included during 30 more days to not loose their MAU value
This commit is contained in:
pare
6a877e6e46
commit
b62782e519
S'han modificat 2 arxius amb 21 adicions i 9 eliminacions
12
database.py
12
database.py
|
@ -312,7 +312,7 @@ class Database():
|
|||
|
||||
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()
|
||||
|
||||
|
@ -326,11 +326,11 @@ class Database():
|
|||
|
||||
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:
|
||||
|
||||
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,))
|
||||
|
||||
|
@ -699,6 +699,7 @@ class Database():
|
|||
soft_version = None
|
||||
first_checked_at = None
|
||||
downs_qty = None
|
||||
mau = 0
|
||||
|
||||
try:
|
||||
|
||||
|
@ -708,7 +709,7 @@ class Database():
|
|||
|
||||
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()
|
||||
|
||||
|
@ -720,6 +721,7 @@ class Database():
|
|||
soft_version = row[3]
|
||||
first_checked_at = row[4]
|
||||
downs_qty = row[5]
|
||||
mau = row[6]
|
||||
|
||||
cur.close()
|
||||
|
||||
|
@ -733,7 +735,7 @@ class Database():
|
|||
|
||||
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):
|
||||
|
||||
|
|
18
fediverse.py
18
fediverse.py
|
@ -48,7 +48,7 @@ class Server:
|
|||
|
||||
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
|
||||
|
||||
|
@ -181,8 +181,6 @@ class Server:
|
|||
|
||||
if not alive:
|
||||
|
||||
mau = 0
|
||||
|
||||
if downs_qty != None:
|
||||
|
||||
downs = downs_qty + 1
|
||||
|
@ -191,7 +189,19 @@ class Server:
|
|||
|
||||
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)
|
||||
|
||||
|
|
Loading…
Referencia en una nova incidència