Fix sync: add missing tables, Linux date, token from env

Add production and consumption table migrations. Fix sync-month.sh
to use Linux date syntax and default to port 3030. Read Eloverblik
token from ELOVERBLIK_TOKEN env var with .token file fallback.
Mount .token into Docker container.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 13:06:14 +01:00
co-authored by Claude Opus 4.6
parent 14b583ccb9
commit 3a319f5cf4
7 changed files with 21 additions and 4 deletions
+2
View File
@@ -5,4 +5,6 @@ services:
- "3030:3030" - "3030:3030"
env_file: env_file:
- .env - .env
volumes:
- ./.token:/app/.token:ro
restart: unless-stopped restart: unless-stopped
@@ -0,0 +1 @@
DROP TABLE production;
@@ -0,0 +1,6 @@
CREATE TABLE production (
time_start TIMESTAMPTZ NOT NULL,
hour INTEGER NOT NULL,
kwh DOUBLE PRECISION,
PRIMARY KEY (time_start, hour)
);
@@ -0,0 +1 @@
DROP TABLE consumption;
@@ -0,0 +1,6 @@
CREATE TABLE consumption (
time_start TIMESTAMPTZ NOT NULL,
hour INTEGER NOT NULL,
kwh DOUBLE PRECISION,
PRIMARY KEY (time_start, hour)
);
@@ -31,7 +31,8 @@
(defn- read-refresh-token (defn- read-refresh-token
[] []
(str/trim (slurp ".token"))) (or (System/getenv "ELOVERBLIK_TOKEN")
(str/trim (slurp ".token"))))
(defn- get-access-token (defn- get-access-token
+3 -3
View File
@@ -9,10 +9,10 @@ if [ $# -ne 1 ]; then
fi fi
MONTH="$1" MONTH="$1"
BASE_URL="${BASE_URL:-http://localhost:3000}" BASE_URL="${BASE_URL:-http://localhost:3030}"
# Last day of the month (macOS date) # Last day of the month
days=$(date -j -v+1m -v-1d -f "%Y-%m-%d" "${MONTH}-01" "+%d") days=$(date -d "${MONTH}-01 +1 month -1 day" "+%d")
echo "Syncing $MONTH ($days days)" echo "Syncing $MONTH ($days days)"