feat: 修改存储频次

This commit is contained in:
caoqianming 2024-06-13 09:04:17 +08:00
parent b5e3553cbc
commit 39ec2047b3
1 changed files with 2 additions and 1 deletions

View File

@ -54,7 +54,8 @@ def save_items(payload):
data['timex'] = datetime.strptime(item['time'], "%Y%m%d%H%M%S").replace(tzinfo=tz.gettz('Asia/Shanghai'))
data['mpoint_id'] = item['name']
last_timex: datetime = mpoint_dict.get(data['mpoint_id'], None)
if last_timex and (data['timex'] - last_timex).total_seconds() < getattr(conf, 'SAVE_SECONDS', 50):
if data["timex"].second not in getattr(conf.SAVE_SECONDS, [2, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57]) or (
last_timex and last_timex.second == data["timex"].second):
continue
try:
val_float = float(item["value"])