From 5a1c927844a5f6c96d73f0b300a154094771e1da Mon Sep 17 00:00:00 2001 From: bbdoc Date: Wed, 7 Dec 2022 16:40:10 +0100 Subject: [PATCH] Add script to ATVMonitor --- wh_receiver/sql/tables.sql | 2 +- wh_receiver/start_whreceiver.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/wh_receiver/sql/tables.sql b/wh_receiver/sql/tables.sql index 91254e6..bbbd1b8 100644 --- a/wh_receiver/sql/tables.sql +++ b/wh_receiver/sql/tables.sql @@ -78,7 +78,7 @@ CREATE TABLE IF NOT EXISTS `ATVMonitor` ( `deviceName` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, `issue` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `action` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - PRIMARY KEY (`deviceName`) + `script` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; CREATE TABLE IF NOT EXISTS `version` ( diff --git a/wh_receiver/start_whreceiver.py b/wh_receiver/start_whreceiver.py index 1326e82..0d7f519 100644 --- a/wh_receiver/start_whreceiver.py +++ b/wh_receiver/start_whreceiver.py @@ -91,13 +91,14 @@ def webhook(): deviceName = validate_string(request.json["deviceName"]) issue = validate_string(request.json["issue"]) action = validate_string(request.json["action"]) + script = validate_string(request.json["script"]) insert_stmt_monitor = ( - "INSERT INTO ATVMonitor (timestamp, deviceName, issue, action)" - "VALUES ( %s, %s, %s, %s )" + "INSERT INTO ATVMonitor (timestamp, deviceName, issue, action, script)" + "VALUES ( %s, %s, %s, %s, %s )" ) - data_monitor = ( str(timestamp), str(deviceName), str(issue), str(action) ) + data_monitor = ( str(timestamp), str(deviceName), str(issue), str(action), str(script) ) try: connection_object = connection_pool.get_connection()