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:
@@ -5,4 +5,6 @@ services:
|
||||
- "3030:3030"
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- ./.token:/app/.token:ro
|
||||
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
|
||||
[]
|
||||
(str/trim (slurp ".token")))
|
||||
(or (System/getenv "ELOVERBLIK_TOKEN")
|
||||
(str/trim (slurp ".token"))))
|
||||
|
||||
|
||||
(defn- get-access-token
|
||||
|
||||
+3
-3
@@ -9,10 +9,10 @@ if [ $# -ne 1 ]; then
|
||||
fi
|
||||
|
||||
MONTH="$1"
|
||||
BASE_URL="${BASE_URL:-http://localhost:3000}"
|
||||
BASE_URL="${BASE_URL:-http://localhost:3030}"
|
||||
|
||||
# Last day of the month (macOS date)
|
||||
days=$(date -j -v+1m -v-1d -f "%Y-%m-%d" "${MONTH}-01" "+%d")
|
||||
# Last day of the month
|
||||
days=$(date -d "${MONTH}-01 +1 month -1 day" "+%d")
|
||||
|
||||
echo "Syncing $MONTH ($days days)"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user