fix SiteStatistic note

This commit is contained in:
jxxghp
2025-08-02 14:23:16 +08:00
parent 0fb7a73fc9
commit f3db27a8da
+4 -6
View File
@@ -198,9 +198,8 @@ class SiteOper(DbOper):
lst_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S") lst_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
sta = SiteStatistic.get_by_domain(self._db, domain) sta = SiteStatistic.get_by_domain(self._db, domain)
if sta: if sta:
avg_seconds, note = None, {} avg_seconds, note = None, sta.note or {}
if seconds is not None: if seconds is not None:
note: dict = sta.note or {}
note[lst_date] = seconds or 1 note[lst_date] = seconds or 1
avg_times = len(note.keys()) avg_times = len(note.keys())
if avg_times > 10: if avg_times > 10:
@@ -211,7 +210,7 @@ class SiteOper(DbOper):
"seconds": avg_seconds or sta.seconds, "seconds": avg_seconds or sta.seconds,
"lst_state": 0, "lst_state": 0,
"lst_mod_date": lst_date, "lst_mod_date": lst_date,
"note": note or sta.note "note": note
}) })
else: else:
note = {} note = {}
@@ -257,9 +256,8 @@ class SiteOper(DbOper):
lst_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S") lst_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
sta = await SiteStatistic.async_get_by_domain(self._db, domain) sta = await SiteStatistic.async_get_by_domain(self._db, domain)
if sta: if sta:
avg_seconds, note = None, {} avg_seconds, note = None, sta.note or {}
if seconds is not None: if seconds is not None:
note: dict = sta.note or {}
note[lst_date] = seconds or 1 note[lst_date] = seconds or 1
avg_times = len(note.keys()) avg_times = len(note.keys())
if avg_times > 10: if avg_times > 10:
@@ -270,7 +268,7 @@ class SiteOper(DbOper):
"seconds": avg_seconds or sta.seconds, "seconds": avg_seconds or sta.seconds,
"lst_state": 0, "lst_state": 0,
"lst_mod_date": lst_date, "lst_mod_date": lst_date,
"note": note or sta.note "note": note
}) })
else: else:
note = {} note = {}