From 0e05dd40ee2c4368c9d298ae9cfdb546a32155ae Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Thu, 6 Jun 2024 00:25:26 +0200 Subject: [PATCH 1/7] Fix #31 --- src/html/prices.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/html/prices.php b/src/html/prices.php index c62af5d..5ba8324 100644 --- a/src/html/prices.php +++ b/src/html/prices.php @@ -2,7 +2,15 @@ require_once 'core.php'; header('Content-Type: application/json'); -$timeframe = 10 * 60; + +// fetch all settings +$query = $pdo->query('SELECT * FROM settings'); +$settings = []; +foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { + $settings[$row['setting']] = $row['value']; +} + +$timeframe = $settings['limit'] * $settings['time_round'] ?? 10 * 60; function roundTo5s($num) { From d96d8253eedaf9a63e71ef1b02ddb586707d20d1 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 5 Jun 2024 22:26:04 +0000 Subject: [PATCH 2/7] =?UTF-8?q?=F0=9F=A7=B9=20Fixed=20code-style?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/html/prices.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/html/prices.php b/src/html/prices.php index 5ba8324..af67bac 100644 --- a/src/html/prices.php +++ b/src/html/prices.php @@ -6,6 +6,7 @@ // fetch all settings $query = $pdo->query('SELECT * FROM settings'); $settings = []; + foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { $settings[$row['setting']] = $row['value']; } From 7f805e3c3f128cb91fd28b5bc1c3ae90b99d5016 Mon Sep 17 00:00:00 2001 From: Martijn <12066560+Kipjr@users.noreply.github.com> Date: Thu, 6 Jun 2024 00:51:24 +0200 Subject: [PATCH 3/7] Fix calculation of timeframe Fix calculation of timeframe (which is a quotient of unix timestamp) --- src/html/prices.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/html/prices.php b/src/html/prices.php index af67bac..20bc1c2 100644 --- a/src/html/prices.php +++ b/src/html/prices.php @@ -11,7 +11,8 @@ $settings[$row['setting']] = $row['value']; } -$timeframe = $settings['limit'] * $settings['time_round'] ?? 10 * 60; +$timeframe = $settings['time_round'] * 60; // quotient of unix timestamp (10 minutes * 60 seconds in a minute) + function roundTo5s($num) { From d33963747ebf07e36d513bb6a54b22b117c5adbe Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 5 Jun 2024 22:52:03 +0000 Subject: [PATCH 4/7] =?UTF-8?q?=F0=9F=A7=B9=20Fixed=20code-style?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/html/prices.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/html/prices.php b/src/html/prices.php index 20bc1c2..06b75cb 100644 --- a/src/html/prices.php +++ b/src/html/prices.php @@ -13,7 +13,6 @@ $timeframe = $settings['time_round'] * 60; // quotient of unix timestamp (10 minutes * 60 seconds in a minute) - function roundTo5s($num) { return round($num * 20) / 20; From 7c5cf5c7829601cfd2180dfadc6629de3a08f708 Mon Sep 17 00:00:00 2001 From: Kipjr <12066560+Kipjr@users.noreply.github.com> Date: Sun, 9 Jun 2024 23:53:33 +0200 Subject: [PATCH 5/7] create persistent storage pma --- docker-compose.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index b4e78de..f18b520 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: hostname: pma image: ghcr.io/linuxserver/phpmyadmin profiles: - - debug + - dev environment: PMA_HOST: '${DB_HOST:-db}' PMA_USER: root @@ -12,9 +12,12 @@ services: TZ: Europe/Amsterdam ports: - '4081:80' + volumes: + - pmadata:/config restart: unless-stopped networks: - net + marktwerking.db: hostname: db container_name: marktwerking.db @@ -67,3 +70,5 @@ networks: volumes: dbdata: driver: local + pmadata: + driver: local From f31835168b92952bd410ede92d62c838115d0a15 Mon Sep 17 00:00:00 2001 From: Kipjr <12066560+Kipjr@users.noreply.github.com> Date: Sun, 9 Jun 2024 23:54:13 +0200 Subject: [PATCH 6/7] add content-type --- src/html/bar/info.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/html/bar/info.php b/src/html/bar/info.php index 71de062..5f25c65 100644 --- a/src/html/bar/info.php +++ b/src/html/bar/info.php @@ -4,6 +4,7 @@ ini_set('display_errors', 1); require_once '../core.php'; +header('Content-Type: application/json'); $data = []; // Grab all categories From 19b98a02fe04038b2fdf8955d76a2542feb735ce Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 9 Jun 2024 21:55:44 +0000 Subject: [PATCH 7/7] =?UTF-8?q?=F0=9F=A7=B9=20Fixed=20code-style?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index f18b520..754ae0f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,11 +13,10 @@ services: ports: - '4081:80' volumes: - - pmadata:/config + - 'pmadata:/config' restart: unless-stopped networks: - net - marktwerking.db: hostname: db container_name: marktwerking.db