From 5ed57780a324f0535ccdf51a8b5c7a89d026e1f7 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sun, 1 Jan 2023 14:33:32 +1100 Subject: [PATCH] better skipcache integration --- back/pialert.py | 4 ++++ docker-compose.yml | 4 ++-- front/php/server/parameters.php | 12 +++++++++--- front/php/templates/header.php | 21 +++++++++++---------- front/php/templates/language/en_us.php | 4 ++-- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/back/pialert.py b/back/pialert.py index ae705f33..14c54da1 100755 --- a/back/pialert.py +++ b/back/pialert.py @@ -549,6 +549,9 @@ def importConfig (): # Used to determine the next import lastTimeImported = time.time() + + # Used to display a message in the UI + sql.executemany ("""INSERT INTO Parameters ("par_ID", "par_Value") VALUES (?, ?)""", [('Back_Settings_Imported', str(lastTimeImported) )]) commitDB() @@ -2875,6 +2878,7 @@ def upgradeDB (): ('Front_Devices_Order', '[[3,"desc"],[0,"asc"]]'), ('Front_Devices_Rows', '100'), ('Front_Details_Tab', 'tabDetails'), + ('Back_Settings_Imported', ''), ('Back_App_State', 'Initializing') ] diff --git a/docker-compose.yml b/docker-compose.yml index 74d02ec6..082c5fac 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,9 +6,9 @@ services: network_mode: "host" restart: unless-stopped volumes: - - ${APP_DATA_LOCATION}/pialert/config2:/home/pi/pialert/config + - ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config # - ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db - - ${APP_DATA_LOCATION}/pialert/db2:/home/pi/pialert/db + - ${APP_DATA_LOCATION}/pialert/db:/home/pi/pialert/db # (optional) map an empty file with the name 'setting_darkmode' if you want to force the dark mode on container rebuilt - ${APP_DATA_LOCATION}/pialert/db/setting_darkmode:/home/pi/pialert/db/setting_darkmode # (optional) useful for debugging if you have issues setting up the container diff --git a/front/php/server/parameters.php b/front/php/server/parameters.php index d4ca0425..fb930c33 100755 --- a/front/php/server/parameters.php +++ b/front/php/server/parameters.php @@ -21,11 +21,17 @@ // Set maximum execution time to 15 seconds ini_set ('max_execution_time','15'); + $skipCache = FALSE; + + if (isset ($_REQUEST['skipcache'])) { + $skipCache = TRUE; + } + // Action functions if (isset ($_REQUEST['action']) && !empty ($_REQUEST['action'])) { $action = $_REQUEST['action']; switch ($action) { - case 'get': getParameter(); break; + case 'get': getParameter($skipCache); break; case 'set': setParameter(); break; default: logServerConsole ('Action: '. $action); break; } @@ -35,7 +41,7 @@ //------------------------------------------------------------------------------ // Get Parameter Value //------------------------------------------------------------------------------ -function getParameter() { +function getParameter($skipCache) { $parameter = $_REQUEST['parameter']; $value = ""; @@ -47,7 +53,7 @@ function getParameter() { } // query the database if no cache entry found or requesting live data for the Back_App_State in the header - if($parameter == "Back_App_State" || $value == "" ) + if($skipCache || $value == "" ) { global $db; diff --git a/front/php/templates/header.php b/front/php/templates/header.php index 4b57e082..f56ffdeb 100755 --- a/front/php/templates/header.php +++ b/front/php/templates/header.php @@ -83,7 +83,7 @@ if ($ENABLED_DARKMODE === True) {