From 370b24fc84ff60d9f64676e31016965ceb3d46f4 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Sun, 8 Dec 2024 06:23:38 +0000 Subject: [PATCH] don't fail on messages without signal level --- rootfs/webapp/acarshub_database.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/rootfs/webapp/acarshub_database.py b/rootfs/webapp/acarshub_database.py index ab8a2fa9..2f090498 100755 --- a/rootfs/webapp/acarshub_database.py +++ b/rootfs/webapp/acarshub_database.py @@ -547,16 +547,17 @@ def add_message(params, message_type, message_from_json, backup=False): # We'll see if the level is in the database already, and if so, increment the counter # If not, we'll add it in - found_level = ( - session.query(messagesLevel) - .filter(messagesLevel.level == params["level"]) - .first() - ) + if params["level"]: + found_level = ( + session.query(messagesLevel) + .filter(messagesLevel.level == params["level"]) + .first() + ) - if found_level is not None: - found_level.count += 1 - else: - session.add(messagesLevel(level=params["level"], count=1)) + if found_level is not None: + found_level.count += 1 + else: + session.add(messagesLevel(level=params["level"], count=1)) if len(params["text"]) > 0 and alert_terms: for search_term in alert_terms: